Skip to content

Commit

Permalink
docs: correct the function description and indentation in `math/base/…
Browse files Browse the repository at this point in the history
…assert/is-odd`

PR-URL: stdlib-js#3070

Reviewed-by: Philipp Burckhardt <[email protected]>
Signed-off-by: Gunj Joshi <[email protected]>
  • Loading branch information
gunjjoshi authored and aayush0325 committed Nov 11, 2024
1 parent f1e725b commit 856329d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
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 );
}

0 comments on commit 856329d

Please sign in to comment.