Skip to content

Latest commit

 

History

History
203 lines (123 loc) · 4.1 KB

File metadata and controls

203 lines (123 loc) · 4.1 KB

sub3

Compute the difference of three double-precision floating-point numbers.

Usage

var sub3 = require( '@stdlib/number/float64/base/sub3' );

sub3( x, y, z )

Computes the difference of three double-precision floating-point numbers.

var v = sub3( 1.0, 5.0, 2.0 );
// returns -6.0

v = sub3( 2.0, 5.0, 2.0 );
// returns -5.0

v = sub3( 0.0, 5.0, 2.0 );
// returns -7.0

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

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

Examples

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

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

logEachMap( 'x: %d, y: %d, z: %d => %d', x, y, z, sub3 );

C APIs

Usage

#include "stdlib/number/float64/base/sub3.h"

stdlib_base_float64_sub3( x, y, z )

Computes the difference of three double-precision floating-point numbers.

double out = stdlib_base_float64_sub3( -5.0, 2.0, 4.0 );
// returns -11.0

The function accepts the following arguments:

  • x: [in] double first input value.
  • y: [in] double second input value.
  • z: [in] double third input value.
double stdlib_base_float64_sub3( const double x, const double y, const double z );

Examples

#include "stdlib/number/float64/base/sub3.h"
#include <stdio.h>

int main( void ) {
    const double x[] = { 3.14, -3.14, 0.0, 0.0/0.0 };
    const double y[] = { 3.14, -3.14, -0.0, 0.0/0.0 };
    const double z[] = { 2.0, -3.0, -0.0, 0.0/0.0 };

    double out;
    int i;
    for ( i = 0; i < 4; i++ ) {
        out = stdlib_base_float64_sub3( x[ i ], y[ i ], z[ i ] );
        printf( "%lf - %lf - %lf = %lf\n", x[ i ], y[ i ], z[ i ], out );
    }
}