Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
#include <stdbool.h>

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

bool b;
int i;
for ( i = 0; i < 6; i++ ) {
b = stdlib_base_is_odd( x[ i ] );
printf( "Value: %lf. Is Odd? %s.\n", x[ i ], ( b ) ? "True" : "False" );
}
bool b;
int i;
for ( i = 0; i < 6; i++ ) {
b = stdlib_base_is_odd( x[ i ] );
printf( "Value: %lf. Is Odd? %s.\n", x[ i ], ( b ) ? "True" : "False" );
}
}
12 changes: 6 additions & 6 deletions lib/node_modules/@stdlib/math/base/assert/is-odd/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include "stdlib/math/base/assert/is_even.h"

/**
* Test if a finite double-precision floating-point number is an odd number.
* Tests if a finite double-precision floating-point number is an odd number.
*
* @param x input value
* @return output value
Expand All @@ -32,9 +32,9 @@
* // returns true
*/
bool stdlib_base_is_odd( const double x ) {
// Check sign to prevent overflow...
if ( x > 0.0 ) {
return stdlib_base_is_even( x - 1.0 );
}
return stdlib_base_is_even( x + 1.0 );
// Check sign to prevent overflow...
if ( x > 0.0 ) {
return stdlib_base_is_even( x - 1.0 );
}
return stdlib_base_is_even( x + 1.0 );
}
Loading