Skip to content

Latest commit

 

History

History
224 lines (137 loc) · 3.95 KB

File metadata and controls

224 lines (137 loc) · 3.95 KB

ceil10f

Round a single-precision floating-point number to the nearest power of 10 toward positive infinity.

Usage

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

ceil10f( x )

Rounds a single-precision floating-point number to the nearest power of 10 toward positive infinity.

var v = ceil10f( -4.2 );
// returns -1.0

v = ceil10f( -4.5 );
// returns -1.0

v = ceil10f( -4.6 );
// returns -1.0

v = ceil10f( 9.99999 );
// returns 10.0

v = ceil10f( 9.5 );
// returns 10.0

v = ceil10f( 13.0 );
// returns 100.0

v = ceil10f( -13.0 );
// returns -10.0

v = ceil10f( 0.0 );
// returns 0.0

v = ceil10f( -0.0 );
// returns -0.0

v = ceil10f( Infinity );
// returns Infinity

v = ceil10f( -Infinity );
// returns -Infinity

v = ceil10f( NaN );
// returns NaN

Notes

  • The function may not return accurate results for subnormals due to a general loss in precision.

    var v = ceil10f( -1.0e-45 ); // should return -1.0e-45
    // returns -0.0

Examples

var uniform = require( '@stdlib/random/array/uniform' );
var logEachMap = require( '@stdlib/console/log-each-map' );
var ceil10f = require( '@stdlib/math/base/special/ceil10f' );

var opts = {
    'dtype': 'float32'
};
var x = uniform( 100, -50.0, 50.0, opts );

logEachMap( 'x: %0.4f. Rounded: %0.4f.', x, ceil10f );

C APIs

Usage

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

stdlib_base_ceil10f( x )

Rounds a single-precision floating-point number to the nearest power of 10 toward positive infinity.

float y = stdlib_base_ceil10f( -4.2f );
// returns -1.0f

The function accepts the following arguments:

  • x: [in] float input value.
float stdlib_base_ceil10f( const float x );

Examples

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

int main( void ) {
    const float x[] = { 3.14f, -3.14f, 0.0f, 0.0f / 0.0f };

    float y;
    int i;
    for ( i = 0; i < 4; i++ ) {
        y = stdlib_base_ceil10f( x[ i ] );
        printf( "ceil10f(%f) = %f\n", x[ i ], y );
    }
}

See Also