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

refactor: remove extra if block, use b instead of base in math/base/special/floorsd #2632

Merged
merged 2 commits into from
Jul 20, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -64,11 +64,7 @@ function floorsd( x, n, b ) {
isnan( x ) ||
isnan( n ) ||
n < 1 ||
isInfinite( n )
) {
return NaN;
}
if (
isInfinite( n ) ||
isnan( b ) ||
b <= 0 ||
isInfinite( b )
Expand Down
10 changes: 4 additions & 6 deletions lib/node_modules/@stdlib/math/base/special/floorsd/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,27 +40,25 @@
* // returns 0.03125
*/
double stdlib_base_floorsd( const double x, const int32_t n, const int32_t b ) {
int32_t base;
double exp;
double s;
double y;

if ( stdlib_base_is_nan( x ) || n < 1 || b <= 0 ) {
return 0.0 / 0.0; // NaN
}
base = b;
if ( stdlib_base_is_infinite( x ) || x == 0.0 ) {
return x;
}
if ( base == 10 ) {
if ( b == 10 ) {
exp = stdlib_base_log10( stdlib_base_abs( x ) );
} else if ( base == 2 ) {
} else if ( b == 2 ) {
exp = stdlib_base_float64_exponent( stdlib_base_abs( x ) );
} else {
exp = stdlib_base_ln( stdlib_base_abs( x ) ) / stdlib_base_ln( base );
exp = stdlib_base_ln( stdlib_base_abs( x ) ) / stdlib_base_ln( b );
kgryte marked this conversation as resolved.
Show resolved Hide resolved
}
exp = stdlib_base_floor( exp - n + 1.0 );
s = stdlib_base_pow( base, stdlib_base_abs( exp ) );
s = stdlib_base_pow( b, stdlib_base_abs( exp ) );
kgryte marked this conversation as resolved.
Show resolved Hide resolved

// Check for overflow:
if ( stdlib_base_is_infinite( s ) ) {
Expand Down
Loading