Skip to content

Commit c14c0c2

Browse files
committed
refactor: use FLOAT64_NUM_HIGH_WORD_SIGNIFICAND_BITS in place of 20
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: passed - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent 08e8478 commit c14c0c2

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

lib/node_modules/@stdlib/math/base/special/modf/lib/assign.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ var PINF = require( '@stdlib/constants/float64/pinf' );
2727
var FLOAT64_EXPONENT_BIAS = require( '@stdlib/constants/float64/exponent-bias' );
2828
var FLOAT64_HIGH_WORD_EXPONENT_MASK = require( '@stdlib/constants/float64/high-word-exponent-mask' ); // eslint-disable-line id-length
2929
var FLOAT64_HIGH_WORD_SIGNIFICAND_MASK = require( '@stdlib/constants/float64/high-word-significand-mask' ); // eslint-disable-line id-length
30+
var FLOAT64_NUM_HIGH_WORD_SIGNIFICAND_BITS = require( '@stdlib/constants/float64/num-high-word-significand-bits' ); // eslint-disable-line id-length
3031

3132

3233
// VARIABLES //
@@ -95,11 +96,11 @@ function modf( x, out, stride, offset ) {
9596
low = WORDS[ 1 ];
9697

9798
// Extract the unbiased exponent from the high word:
98-
exp = ((high & FLOAT64_HIGH_WORD_EXPONENT_MASK) >> 20)|0; // asm type annotation
99+
exp = ((high & FLOAT64_HIGH_WORD_EXPONENT_MASK) >> FLOAT64_NUM_HIGH_WORD_SIGNIFICAND_BITS)|0; // asm type annotation
99100
exp -= FLOAT64_EXPONENT_BIAS|0; // asm type annotation
100101

101102
// Handle smaller values (x < 2**20 = 1048576)...
102-
if ( exp < 20 ) {
103+
if ( exp < FLOAT64_NUM_HIGH_WORD_SIGNIFICAND_BITS ) {
103104
i = (FLOAT64_HIGH_WORD_SIGNIFICAND_MASK >> exp)|0; // asm type annotation
104105

105106
// Determine if `x` is integral by checking for significand bits which cannot be exponentiated away...
@@ -126,7 +127,7 @@ function modf( x, out, stride, offset ) {
126127
out[ offset + stride ] = 0.0;
127128
return out;
128129
}
129-
i = ALL_ONES >>> (exp-20);
130+
i = ALL_ONES >>> ( exp - FLOAT64_NUM_HIGH_WORD_SIGNIFICAND_BITS );
130131

131132
// Determine if `x` is integral by checking for less significant significand bits which cannot be exponentiated away...
132133
if ( (low&i) === 0 ) {

lib/node_modules/@stdlib/math/base/special/modf/manifest.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@
4646
"@stdlib/constants/float64/pinf",
4747
"@stdlib/constants/float64/exponent-bias",
4848
"@stdlib/constants/float64/high-word-exponent-mask",
49-
"@stdlib/constants/float64/high-word-significand-mask"
49+
"@stdlib/constants/float64/high-word-significand-mask",
50+
"@stdlib/constants/float64/num-high-word-significand-bits"
5051
]
5152
},
5253
{
@@ -66,7 +67,8 @@
6667
"@stdlib/constants/float64/pinf",
6768
"@stdlib/constants/float64/exponent-bias",
6869
"@stdlib/constants/float64/high-word-exponent-mask",
69-
"@stdlib/constants/float64/high-word-significand-mask"
70+
"@stdlib/constants/float64/high-word-significand-mask",
71+
"@stdlib/constants/float64/num-high-word-significand-bits"
7072
]
7173
},
7274
{
@@ -86,7 +88,8 @@
8688
"@stdlib/constants/float64/pinf",
8789
"@stdlib/constants/float64/exponent-bias",
8890
"@stdlib/constants/float64/high-word-exponent-mask",
89-
"@stdlib/constants/float64/high-word-significand-mask"
91+
"@stdlib/constants/float64/high-word-significand-mask",
92+
"@stdlib/constants/float64/num-high-word-significand-bits"
9093
]
9194
}
9295
]

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "stdlib/constants/float64/exponent_bias.h"
2525
#include "stdlib/constants/float64/high_word_exponent_mask.h"
2626
#include "stdlib/constants/float64/high_word_significand_mask.h"
27+
#include "stdlib/constants/float64/num_high_word_significand_bits.h"
2728

2829
// 4294967295 => 0xffffffff => 11111111111111111111111111111111
2930
static const uint32_t ALL_ONES = 4294967295;
@@ -82,11 +83,11 @@ void stdlib_base_modf( const double x, double* integral, double* frac ) {
8283
stdlib_base_float64_to_words( x, &high, &low );
8384

8485
// Extract the unbiased exponent from the high word:
85-
exp = ( ( high & STDLIB_CONSTANT_FLOAT64_HIGH_WORD_EXPONENT_MASK ) >> 20 );
86+
exp = ( ( high & STDLIB_CONSTANT_FLOAT64_HIGH_WORD_EXPONENT_MASK ) >> STDLIB_CONSTANT_FLOAT64_NUM_HIGH_WORD_SIGNIFICAND_BITS );
8687
exp -= ( STDLIB_CONSTANT_FLOAT64_EXPONENT_BIAS );
8788

8889
// Handle smaller values (x < 2**20 = 1048576)...
89-
if( exp < 20 ) {
90+
if( exp < STDLIB_CONSTANT_FLOAT64_NUM_HIGH_WORD_SIGNIFICAND_BITS ) {
9091
i = ( STDLIB_CONSTANT_FLOAT64_HIGH_WORD_SIGNIFICAND_MASK >> exp );
9192

9293
// Determine if `x` is integral by checking for significand bits which cannot be exponentiated away...
@@ -111,7 +112,7 @@ void stdlib_base_modf( const double x, double* integral, double* frac ) {
111112
*frac = 0.0;
112113
return;
113114
}
114-
i = ALL_ONES >> ( exp - 20 );
115+
i = ALL_ONES >> ( exp - STDLIB_CONSTANT_FLOAT64_NUM_HIGH_WORD_SIGNIFICAND_BITS );
115116

116117
// Determine if `x` is integral by checking for less significant significand bits which cannot be exponentiated away...
117118
if ( ( low & i ) == 0 ) {

0 commit comments

Comments
 (0)