isNegativeFinite

Test if a double-precision floating-point numeric value is a negative finite number.

Usage

var isNegativeFinite = require( '@stdlib/math/base/assert/is-negative-finite' );

isNegativeFinite( x )

Tests if a double-precision floating-point numeric value is a negative finite number.

var bool = isNegativeFinite( -3.14 );
// returns true

bool = isNegativeFinite( 2.0 );
// returns false

Examples

var isNegativeFinite = require( '@stdlib/math/base/assert/is-negative-finite' );

var bool = isNegativeFinite( -3.14 );
// returns true

bool = isNegativeFinite( 3.14 );
// returns false

bool = isNegativeFinite( 0.0 );
// returns false

bool = isNegativeFinite( -0.0 );
// returns false

bool = isNegativeFinite( NaN );
// returns false

C APIs

Usage

#include "stdlib/math/base/assert/is_negative_finite.h"

stdlib_base_is_negative_finite( x )

Tests if a double-precision floating-point numeric value is a negative finite number.

#include <stdbool.h>

bool out = stdlib_base_is_negative_finite( 1.0 );
// returns false

out = stdlib_base_is_negative_finite( -4.0 );
// returns true

The function accepts the following arguments:

  • x: [in] double input value.
bool stdlib_base_is_negative_finite( const double x );

Examples

#include "stdlib/math/base/assert/is_negative_finite.h"
#include "stdlib/constants/float64/ninf.h"
#include <stdio.h>
#include <stdbool.h>

int main( void ) {
    const double x[] = { 5.0, -5.0, 3.14, -3.14, 0.0/0.0, STDLIB_CONSTANT_FLOAT64_NINF };

    bool b;
    int i;
    for ( i = 0; i < 6; i++ ) {
        b = stdlib_base_is_negative_finite( x[ i ] );
        printf( "x = %lf, is_negative_finite(x) = %s\n", x[ i ], ( b ) ? "True" : "False" );
    }
}
Did you find this page helpful?