minf

Return the minimum single-precision floating-point number.

Usage

var minf = require( '@stdlib/math/base/special/minf' );

minf( x, y )

Returns the minimum single-precision floating-point number.

var v = minf( 4.2, 3.14 );
// returns 3.14

v = minf( +0.0, -0.0 );
// returns -0.0

If any argument is NaN, the function returns NaN.

var v = minf( 4.2, NaN );
// returns NaN

v = minf( NaN, 3.14 );
// returns NaN

Examples

var minstd = require( '@stdlib/random/base/minstd-shuffle' );
var minf = require( '@stdlib/math/base/special/minf' );

var x;
var y;
var v;
var i;

for ( i = 0; i < 100; i++ ) {
    x = minstd();
    y = minstd();
    v = minf( x, y );
    console.log( 'minf(%d,%d) = %d', x, y, v );
}

C APIs

Usage

#include "stdlib/math/base/special/minf.h"

stdlib_base_minf( x, y )

Returns the minimum single-precision floating-point number.

float out = stdlib_base_minf( 4.2f, 3.14f );
// returns 3.14f

out = stdlib_base_minf( 0.0f, -0.0f );
// returns -0.0f

The function accepts the following arguments:

  • x: [in] float input value.
  • y: [in] float input value.
float stdlib_base_minf( const float x, const float y );

Examples

#include "stdlib/math/base/special/minf.h"
#include <stdlib.h>
#include <stdio.h>

int main( void ) {
    float x;
    float y;
    float v;
    int i;
    
    for ( i = 0; i < 100; i++ ) {
        x = ( ( (float)rand() / (float)RAND_MAX ) * 200.0f ) - 100.0f;
        y = ( ( (float)rand() / (float)RAND_MAX ) * 200.0f ) - 100.0f;
        v = stdlib_base_minf( x, y );
        printf( "x: %f, y: %f, minf(x, y): %f\n", x, y, v );
    }
}
Did you find this page helpful?