Skip to content

Commit

Permalink
chore: apply suggestions from code review
Browse files Browse the repository at this point in the history
Signed-off-by: Pranav <85227306+Pranavchiku@users.noreply.github.com>
  • Loading branch information
Pranavchiku authored Mar 8, 2024
1 parent b4f21da commit 1add6b7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ bool = isNegativeFinite( NaN );
Tests if a double-precision floating-point numeric value is a negative finite number.

```c
#include <stdbool.h>

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

Expand Down Expand Up @@ -147,18 +149,17 @@ bool stdlib_base_is_negative_finite( const double x );
```c
#include "stdlib/math/base/assert/is_negative_finite.h"
#include "stdlib/constants/float64/ninf.h"
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
int main( void ) {
double x;
bool v;
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 < 100; i++ ) {
x = ( ( (double)rand() / (double)RAND_MAX ) * 100.0 );
v = stdlib_base_is_negative_finite( x );
for ( i = 0; i < 6; i++ ) {
b = stdlib_base_is_negative_finite( x[ i ] );
printf( "x = %lf, is_negative_finite(x) = %s\n", x, ( v ) ? "True" : "False" );
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ bench( pkg, opts, function benchmark( b ) {

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
x = (randu()*200.0) - 100.0;
x = ( randu()*200.0 ) - 100.0;
y = isNegativeFinite( x );
if ( typeof y !== 'boolean' ) {
b.fail( 'should return a boolean' );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,16 @@
*/

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

int main( void ) {
double x;
bool v;
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 < 100; i++ ) {
x = ( ( (double)rand() / (double)RAND_MAX ) * 100.0 );
v = stdlib_base_is_negative_finite( x );
for ( i = 0; i < 6; i++ ) {
b = stdlib_base_is_negative_finite( x[ i ] );
printf( "x = %lf, is_negative_finite(x) = %s\n", x, ( v ) ? "True" : "False" );
}
}

0 comments on commit 1add6b7

Please sign in to comment.