Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: correct the function description and indentation in math/base/assert/is-odd #3070

Merged
merged 3 commits into from
Nov 9, 2024
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