@stdlib/math-base-special-nanmin
v0.1.1
Published
Return the minimum value, ignoring NaN.
Readme
nanmin
Return the minimum value, ignoring NaN.
Installation
npm install @stdlib/math-base-special-nanminUsage
var nanmin = require( '@stdlib/math-base-special-nanmin' );nanmin( x, y )
Returns the minimum value.
var v = nanmin( 4.2, 3.14 );
// returns 3.14
v = nanmin( +0.0, -0.0 );
// returns -0.0If any argument is NaN, the function returns the other operand.
var v = nanmin( 4.2, NaN );
// returns 4.2
v = nanmin( NaN, 3.14 );
// returns 3.14If both arguments are NaN, the function returns NaN.
var v = nanmin( NaN, NaN );
// returns NaNExamples
var nanmin = require( '@stdlib/math-base-special-nanmin' );
var m = nanmin( 3.0, 4.0 );
console.log( m );
// => 3.0
m = nanmin( NaN, 4.0 );
console.log( m );
// => 4.0
m = nanmin( 4.0, NaN );
console.log( m );
// => 4.0
m = nanmin( NaN, NaN );
console.log( m );
// => NaNC APIs
Usage
#include "stdlib/math/base/special/nanmin.h"stdlib_base_nanmin( x, y )
Returns the minimum value, ignoring NaN.
double out = stdlib_base_nanmin( 4.2, 3.14 );
// returns 3.14
out = stdlib_base_nanmin( 4.14, 0.0 / 0.0 );
// returns 4.14The function accepts the following arguments:
- x:
[in] doubleinput value. - y:
[in] doubleinput value.
double stdlib_base_nanmin( const double x, const double y );Examples
#include "stdlib/math/base/special/nanmin.h"
#include <stdio.h>
int main( void ) {
const double x[] = { 1.0, 0.45, -0.89, 0.0 / 0.0, -0.78, -0.22, 0.66, 0.11, -0.55, 0.0 };
const double y[] = { -0.22, 0.66, 0.0, -0.55, 0.33, 1.0, 0.0 / 0.0, 0.11, 0.45, -0.78 };
double v;
int i;
for ( i = 0; i < 10; i++ ) {
v = stdlib_base_nanmin( x[i], y[i] );
printf( "x[ %d ]: %lf, y[ %d ]: %lf, nanmin( x[ %d ], y[ %d ] ): %lf\n", i, x[ i ], i, y[ i ], i, i, v );
}
}Notice
This package is part of stdlib, a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.
For more information on the project, filing bug reports and feature requests, and guidance on how to develop stdlib, see the main project repository.
Community
License
See LICENSE.
Copyright
Copyright © 2016-2026. The Stdlib Authors.
