maxf
Return the maximum single-precision floating-point number.
Usage
var maxf = require( '@stdlib/math/base/special/maxf' );
maxf( x, y )
Returns the maximum single-precision floating-point number.
var v = maxf( 4.2, 3.14 );
// returns 4.2
v = maxf( +0.0, -0.0 );
// returns +0.0
If any argument is NaN
, the function returns NaN
.
var v = maxf( 4.2, NaN );
// returns NaN
v = maxf( NaN, 3.14 );
// returns NaN
Examples
var minstd = require( '@stdlib/random/base/minstd-shuffle' );
var maxf = require( '@stdlib/math/base/special/maxf' );
var x;
var y;
var v;
var i;
for ( i = 0; i < 100; i++ ) {
x = minstd();
y = minstd();
v = maxf( x, y );
console.log( 'maxf(%d,%d) = %d', x, y, v );
}
C APIs
Usage
#include "stdlib/math/base/special/maxf.h"
stdlib_base_maxf( x, y )
Returns the maximum single-precision floating-point number.
float out = stdlib_base_maxf( 4.2f, 3.14f );
// returns 4.2f
out = stdlib_base_maxf( 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_maxf( const float x, const float y );
Examples
#include "stdlib/math/base/special/maxf.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_maxf( x, y );
printf( "x: %f, y: %f, maxf(x, y): %f\n", x, y, v );
}
}