Round a double-precision floating-point number toward negative infinity.
var floor = require( '@stdlib/math/base/special/floor' );Rounds a double-precision floating-point number toward negative infinity.
var v = floor( -4.2 );
// returns -5.0
v = floor( 9.99999 );
// returns 9.0
v = floor( 0.0 );
// returns 0.0
v = floor( NaN );
// returns NaNvar uniform = require( '@stdlib/random/array/uniform' );
var logEachMap = require( '@stdlib/console/log-each-map' );
var floor = require( '@stdlib/math/base/special/floor' );
var opts = {
'dtype': 'float64'
};
var x = uniform( 100, -50.0, 50.0, opts );
logEachMap( 'floor(%0.4f) = %d', x, floor );#include "stdlib/math/base/special/floor.h"Rounds a double-precision floating-point number toward negative infinity.
double y = stdlib_base_floor( 3.14 );
// returns 3.0The function accepts the following arguments:
- x:
[in] doubleinput value.
double stdlib_base_floor( const double x );#include "stdlib/math/base/special/floor.h"
#include <stdio.h>
int main( void ) {
const double x[] = { 3.14, -3.14, 0.0, 0.0/0.0 };
double y;
int i;
for ( i = 0; i < 4; i++ ) {
y = stdlib_base_floor( x[ i ] );
printf( "floor(%lf) = %lf\n", x[ i ], y );
}
}@stdlib/math/base/special/ceil: round a double-precision floating-point number toward positive infinity.@stdlib/math/base/special/round: round a numeric value to the nearest integer.