Compute the sum of two single-precision floating-point numbers.
var addf = require( '@stdlib/number/float32/base/add' );Computes the sum of two single-precision floating-point numbers.
var v = addf( -1.0, 5.0 );
// returns 4.0
v = addf( 2.0, 5.0 );
// returns 7.0
v = addf( 0.0, 5.0 );
// returns 5.0
v = addf( -0.0, 0.0 );
// returns 0.0
v = addf( NaN, NaN );
// returns NaNvar discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
var logEachMap = require( '@stdlib/console/log-each-map' );
var addf = require( '@stdlib/number/float32/base/add' );
var x = discreteUniform( 100, -50, 50 );
var y = discreteUniform( 100, -50, 50 );
logEachMap( '%d + %d = %d', x, y, addf );#include "stdlib/number/float32/base/add.h"Computes the sum of two single-precision floating-point numbers.
float v = stdlib_base_float32_add( -5.0f, 2.0f );
// returns -3.0fThe function accepts the following arguments:
- x:
[in] floatfirst input value. - y:
[in] floatsecond input value.
float stdlib_base_float32_add( const float x, const float y );#include "stdlib/number/float32/base/add.h"
#include <stdio.h>
int main( void ) {
const float x[] = { 3.14f, -3.14f, 0.0f, 0.0f/0.0f };
const float y[] = { 3.14f, -3.14f, -0.0f, 0.0f/0.0f };
float z;
int i;
for ( i = 0; i < 4; i++ ) {
z = stdlib_base_float32_add( x[ i ], y[ i ] );
printf( "%f + %f = %f\n", x[ i ], y[ i ], z );
}
}@stdlib/number/float64/base/add: compute the sum of two double-precision floating-point numbers.@stdlib/number/float32/base/div: divide two single-precision floating-point numbers.@stdlib/number/float32/base/mul: multiply two single-precision floating-point numbers.@stdlib/number/float32/base/sub: subtract two single-precision floating-point numbers.