Base 2 exponential function.
We believe in a future in which the web is a preferred environment for numerical computation. To help realize this future, we’ve built stdlib. stdlib is a standard library, with an emphasis on numerical and scientific computation, written in JavaScript (and C) for execution in browsers and in Node.js.
The library is fully decomposable, being architected in such a way that you can swap out and mix and match APIs and functionality to cater to your exact preferences and use cases.
When you use stdlib, you can be absolutely certain that you are using the most thorough, rigorous, well-written, studied, documented, tested, measured, and high-quality code out there.
To join us in bringing numerical computing to the web, get started by checking us out on GitHub, and please consider financially supporting stdlib. We greatly appreciate your continued support!
[![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url]
Base
2
[exponential function][exponential-function].
bash
npm install @stdlib/math-base-special-exp2
script
tag without installation and bundlers, use the [ES Module][es-module] available on the [esm
][esm-url] branch (see [README][esm-readme]).deno
][deno-url] branch (see [README][deno-readme] for usage intructions).umd
][umd-url] branch (see [README][umd-readme]).javascript
var exp2 = require( '@stdlib/math-base-special-exp2' );
2
[exponential function][exponential-function].javascript
var v = exp2( 3.0 );
// returns 8.0
v = exp2( -9.0 );
// returns ~0.002
v = exp2( 0.0 );
// returns 1.0
v = exp2( NaN );
// returns NaN
javascript
var uniform = require( '@stdlib/random-array-uniform' );
var logEachMap = require( '@stdlib/console-log-each-map' );
var exp2 = require( '@stdlib/math-base-special-exp2' );
var opts = {
'dtype': 'float64'
};
var x = uniform( 100, -50.0, 50.0, opts );
logEachMap( '2^%0.4f = %0.4f', x, exp2 );
c
#include "stdlib/math/base/special/exp2.h"
2
[exponential function][exponential-function].c
double out = stdlib_base_exp2( 3.0 );
// returns 8.0
out = stdlib_base_exp2( -9.0 );
// returns ~0.002
[in] double
input value.c
double stdlib_base_exp2( const double x );
c
#include "stdlib/math/base/special/exp2.h"
#include <stdlib.h>
#include <stdio.h>
int main( void ) {
double x;
double v;
int i;
for ( i = 0; i < 100; i++ ) {
x = ( ( (double)rand() / (double)RAND_MAX ) * 100.0 ) - 50.0;
v = stdlib_base_exp2( x );
printf( "2^%lf = %lf\n", x, v );
}
}