Skip to content

Commit b063947

Browse files
gunjjoshikgryte
andauthored
refactor: reduce code complexity
PR-URL: #2632 Co-authored-by: Athan Reines <kgryte@gmail.com> Reviewed-by: Athan Reines <kgryte@gmail.com> Signed-off-by: Athan Reines <kgryte@gmail.com>
1 parent 4345839 commit b063947

File tree

2 files changed

+5
-11
lines changed
  • lib/node_modules/@stdlib/math/base/special/floorsd

2 files changed

+5
-11
lines changed

lib/node_modules/@stdlib/math/base/special/floorsd/lib/main.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,7 @@ function floorsd( x, n, b ) {
6464
isnan( x ) ||
6565
isnan( n ) ||
6666
n < 1 ||
67-
isInfinite( n )
68-
) {
69-
return NaN;
70-
}
71-
if (
67+
isInfinite( n ) ||
7268
isnan( b ) ||
7369
b <= 0 ||
7470
isInfinite( b )

lib/node_modules/@stdlib/math/base/special/floorsd/src/main.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,27 +40,25 @@
4040
* // returns 0.03125
4141
*/
4242
double stdlib_base_floorsd( const double x, const int32_t n, const int32_t b ) {
43-
int32_t base;
4443
double exp;
4544
double s;
4645
double y;
4746

4847
if ( stdlib_base_is_nan( x ) || n < 1 || b <= 0 ) {
4948
return 0.0 / 0.0; // NaN
5049
}
51-
base = b;
5250
if ( stdlib_base_is_infinite( x ) || x == 0.0 ) {
5351
return x;
5452
}
55-
if ( base == 10 ) {
53+
if ( b == 10 ) {
5654
exp = stdlib_base_log10( stdlib_base_abs( x ) );
57-
} else if ( base == 2 ) {
55+
} else if ( b == 2 ) {
5856
exp = stdlib_base_float64_exponent( stdlib_base_abs( x ) );
5957
} else {
60-
exp = stdlib_base_ln( stdlib_base_abs( x ) ) / stdlib_base_ln( base );
58+
exp = stdlib_base_ln( stdlib_base_abs( x ) ) / stdlib_base_ln( (double)b );
6159
}
6260
exp = stdlib_base_floor( exp - n + 1.0 );
63-
s = stdlib_base_pow( base, stdlib_base_abs( exp ) );
61+
s = stdlib_base_pow( (double)b, stdlib_base_abs( exp ) );
6462

6563
// Check for overflow:
6664
if ( stdlib_base_is_infinite( s ) ) {

0 commit comments

Comments
 (0)