Skip to content

Latest commit

 

History

History

README.md

mulf

Multiply two single-precision floating-point numbers.

Usage

var mulf = require( '@stdlib/number/float32/base/mul' );

mulf( x, y )

Multiplies two single-precision floating-point numbers.

var v = mulf( -1.0, 5.0 );
// returns -5.0

v = mulf( 2.0, 5.0 );
// returns 10.0

v = mulf( 0.0, 5.0 );
// returns 0.0

v = mulf( -0.0, 0.0 );
// returns -0.0

v = mulf( NaN, NaN );
// returns NaN

Examples

var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
var logEachMap = require( '@stdlib/console/log-each-map' );
var mulf = require( '@stdlib/number/float32/base/mul' );

var x = discreteUniform( 100, -50, 50 );
var y = discreteUniform( 100, -50, 50 );

logEachMap( '%d x %d = %d', x, y, mulf );

C APIs

Usage

#include "stdlib/number/float32/base/mul.h"

stdlib_base_float32_mul( x, y )

Multiplies two single-precision floating-point numbers.

float v = stdlib_base_float32_mul( -5.0f, 2.0f );
// returns -10.0f

The function accepts the following arguments:

  • x: [in] float first input value.
  • y: [in] float second input value.
float stdlib_base_float32_mul( const float x, const float y );

Examples

#include "stdlib/number/float32/base/mul.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_mul( x[ i ], y[ i ] );
        printf( "%f x %f = %f\n", x[ i ], y[ i ], z );
    }
}

See Also