nanmaxf

Return the maximum value of two single-precision floating-point numbers, ignoring NaN.

Usage

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

nanmaxf( x, y )

Returns the maximum value of two single-precision floating-point numbers, ignoring NaN.

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

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

If any argument is NaN, the function returns the other operand.

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

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

If both arguments are NaN, the function returns NaN.

var v = nanmaxf( NaN, NaN );
// returns NaN

Examples

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

var m = nanmaxf( 3.0, 4.0 );
console.log( m );
// => 4.0

m = nanmaxf( NaN, 4.0 );
console.log( m );
// => 4.0

m = nanmaxf( 4.0, NaN );
console.log( m );
// => 4.0

m = nanmaxf( NaN, NaN );
console.log( m );
// => NaN

C APIs

Usage

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

stdlib_base_nanmaxf( x, y )

Returns the maximum value of two single-precision floating-point numbers, ignoring NaN.

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

out = stdlib_base_nanmaxf( 4.14f, 0.0f / 0.0f );
// returns 4.14f

The function accepts the following arguments:

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

Examples

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

int main( void ) {
    const float x[] = { 1.0f, 0.45f, -0.89f, 0.0f / 0.0f, -0.78f, -0.22f, 0.66f, 0.11f, -0.55f, 0.0f };
    const float y[] = { -0.22f, 0.66f, 0.0f, -0.55f, 0.33f, 1.0f, 0.0f / 0.0f, 0.11f, 0.45f, -0.78f };

    float v;
    int i;
    for ( i = 0; i < 10; i++ ) {
        v = stdlib_base_nanmaxf( x[ i ], y[ i ] );
        printf( "x[ %d ]: %f, y[ %d ]: %f, nanmaxf( x[ %d ], y[ %d ] ): %f\n", i, x[ i ], i, y[ i ], i, i, v );
    }
}
Did you find this page helpful?