Skip to content

Latest commit

 

History

History
202 lines (123 loc) · 4.36 KB

File metadata and controls

202 lines (123 loc) · 4.36 KB

exp2f

Base 2 exponential function (single-precision).

Usage

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

exp2f( x )

Evaluates the base 2 exponential function.

var v = exp2f( 3.0 );
// returns 8.0

v = exp2f( -9.0 );
// returns ~0.002

v = exp2f( 0.0 );
// returns 1.0

v = exp2f( NaN );
// returns NaN

Examples

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

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

logEachMap( '2^%0.4f = %0.4f', x, exp2f );

C APIs

Usage

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

stdlib_base_exp2f( x )

Evaluates the base 2 exponential function.

float out = stdlib_base_exp2f( 3.0f );
// returns 8.0f

out = stdlib_base_exp2f( -9.0f );
// returns ~0.002f

The function accepts the following arguments:

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

Examples

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

int main( void ) {
    float x;
    float v;
    int i;

    for ( i = 0; i < 100; i++ ) {
        x = ( ( (float)rand() / (float)RAND_MAX ) * 100.0f ) - 50.0f;
        v = stdlib_base_exp2f( x );
        printf( "2^%f = %f\n", x, v );
    }
}

See Also