@@ -23,16 +23,16 @@ <h1><a href="index.html">All files</a> main.js</h1>
2323 < div class ='clearfix '>
2424
2525 < div class ='fl pad1y space-right2 '>
26- < span class ="strong "> 90.37 % </ span >
26+ < span class ="strong "> 90% </ span >
2727 < span class ="quiet "> Statements</ span >
28- < span class ='fraction '> 169/187 </ span >
28+ < span class ='fraction '> 162/180 </ span >
2929 </ div >
3030
3131
3232 < div class ='fl pad1y space-right2 '>
33- < span class ="strong "> 81.25 % </ span >
33+ < span class ="strong "> 80 % </ span >
3434 < span class ="quiet "> Branches</ span >
35- < span class ='fraction '> 26/32 </ span >
35+ < span class ='fraction '> 24/30 </ span >
3636 </ div >
3737
3838
@@ -44,9 +44,9 @@ <h1><a href="index.html">All files</a> main.js</h1>
4444
4545
4646 < div class ='fl pad1y space-right2 '>
47- < span class ="strong "> 90.37 % </ span >
47+ < span class ="strong "> 90% </ span >
4848 < span class ="quiet "> Lines</ span >
49- < span class ='fraction '> 169/187 </ span >
49+ < span class ='fraction '> 162/180 </ span >
5050 </ div >
5151
5252
@@ -243,14 +243,7 @@ <h1><a href="index.html">All files</a> main.js</h1>
243243< a name ='L178 '> </ a > < a href ='#L178 '> 178</ a >
244244< a name ='L179 '> </ a > < a href ='#L179 '> 179</ a >
245245< a name ='L180 '> </ a > < a href ='#L180 '> 180</ a >
246- < a name ='L181 '> </ a > < a href ='#L181 '> 181</ a >
247- < a name ='L182 '> </ a > < a href ='#L182 '> 182</ a >
248- < a name ='L183 '> </ a > < a href ='#L183 '> 183</ a >
249- < a name ='L184 '> </ a > < a href ='#L184 '> 184</ a >
250- < a name ='L185 '> </ a > < a href ='#L185 '> 185</ a >
251- < a name ='L186 '> </ a > < a href ='#L186 '> 186</ a >
252- < a name ='L187 '> </ a > < a href ='#L187 '> 187</ a >
253- < a name ='L188 '> </ a > < a href ='#L188 '> 188</ a > </ td > < td class ="line-coverage quiet "> < span class ="cline-any cline-yes "> 1x</ span >
246+ < a name ='L181 '> </ a > < a href ='#L181 '> 181</ a > </ td > < td class ="line-coverage quiet "> < span class ="cline-any cline-yes "> 1x</ span >
254247< span class ="cline-any cline-yes "> 1x</ span >
255248< span class ="cline-any cline-yes "> 1x</ span >
256249< span class ="cline-any cline-yes "> 1x</ span >
@@ -311,9 +304,6 @@ <h1><a href="index.html">All files</a> main.js</h1>
311304< span class ="cline-any cline-yes "> 5005x</ span >
312305< span class ="cline-any cline-yes "> 5005x</ span >
313306< span class ="cline-any cline-yes "> 5005x</ span >
314- < span class ="cline-any cline-yes "> 5005x</ span >
315- < span class ="cline-any cline-yes "> 5005x</ span >
316- < span class ="cline-any cline-yes "> 5005x</ span >
317307< span class ="cline-any cline-yes "> 1x</ span >
318308< span class ="cline-any cline-yes "> 1x</ span >
319309< span class ="cline-any cline-yes "> 5005x</ span >
@@ -346,10 +336,6 @@ <h1><a href="index.html">All files</a> main.js</h1>
346336< span class ="cline-any cline-yes "> 4996x</ span >
347337< span class ="cline-any cline-yes "> 4996x</ span >
348338< span class ="cline-any cline-yes "> 4996x</ span >
349- < span class ="cline-any cline-yes "> 4996x</ span >
350- < span class ="cline-any cline-yes "> 4996x</ span >
351- < span class ="cline-any cline-yes "> 4996x</ span >
352- < span class ="cline-any cline-yes "> 4996x</ span >
353339< span class ="cline-any cline-yes "> 5005x</ span >
354340< span class ="cline-any cline-no "> </ span >
355341< span class ="cline-any cline-no "> </ span >
@@ -408,9 +394,9 @@ <h1><a href="index.html">All files</a> main.js</h1>
408394< span class ="cline-any cline-yes "> 3996x</ span >
409395< span class ="cline-any cline-yes "> 3996x</ span >
410396< span class ="cline-any cline-yes "> 3996x</ span >
411- < span class ="cline-any cline-yes "> 5005x </ span >
412- < span class ="cline-any cline-yes "> 5005x </ span >
413- < span class ="cline-any cline-yes "> 5005x </ span >
397+ < span class ="cline-any cline-yes "> 3996x </ span >
398+ < span class ="cline-any cline-yes "> 3996x </ span >
399+ < span class ="cline-any cline-yes "> 3996x </ span >
414400< span class ="cline-any cline-yes "> 5005x</ span >
415401< span class ="cline-any cline-yes "> 1988x</ span >
416402< span class ="cline-any cline-yes "> 1988x</ span >
@@ -465,7 +451,7 @@ <h1><a href="index.html">All files</a> main.js</h1>
465451var abs = require( '@stdlib/math/base/special/abs' );
466452var exponent = require( '@stdlib/number/float64/base/exponent' );
467453var isNegativeZero = require( '@stdlib/assert/is-negative-zero' );
468- var toWords = require( '@stdlib/number/float64 /base/to-words ' );
454+ var toWordf = require( '@stdlib/number/float32 /base/to-word ' );
469455
470456
471457// MAIN //
@@ -486,18 +472,15 @@ <h1><a href="index.html">All files</a> main.js</h1>
486472* // returns 15411
487473*/
488474function toWord( x ) {
489- var mantissaHigh;
490- var mantissaLow;
491- var f64Exponent;
475+ var f32Exponent;
492476 var f16Exponent;
493477 var stickyBits;
494478 var mantissa;
495479 var roundBit;
496480 var shift;
481+ var bits;
482+ var mant;
497483 var sign;
498- var high;
499- var low;
500- var w;
501484
502485 // Handle special cases
503486 if ( isnan( x ) ) { // NaN
@@ -522,19 +505,15 @@ <h1><a href="index.html">All files</a> main.js</h1>
522505 sign = 0;
523506 }
524507 x = abs( x );
508+ bits = toWordf( x );
525509
526- w = toWords( x );
527- high = w[ 0 ]; // high 32 bits
528- low = w[ 1 ]; // low 32 bits
529-
530- mantissaHigh = high & 0xFFFFF; // 20 bits: mantissa[51:32]
531- mantissaLow = low; // 32 bits: mantissa[31:0]
510+ mant = bits & 0x7FFFFF; // 23-bit mantissa
532511
533- // Store unbiased exponent of a 64 -bit floating-point number.
534- f64Exponent = exponent( x );
512+ // Store unbiased exponent of a 32 -bit floating-point number.
513+ f32Exponent = exponent( x );
535514
536515 // Calculate exponent of a 16-bit floating-point number.
537- f16Exponent = f64Exponent + 15;
516+ f16Exponent = f32Exponent + 15;
538517
539518 // Handle overflow (infinity in float16)
540519 if ( f16Exponent >= 31 ) < span class ="branch-0 cbranch-no " title ="branch not covered " > {</ span >
@@ -554,8 +533,8 @@ <h1><a href="index.html">All files</a> main.js</h1>
554533 // Calculate the amount of right shift needed to denormalize the mantissa for subnormal representation:
555534 shift = 1 - f16Exponent;
556535
557- // Create an 11-bit mantissa by adding the implicit leading 1 bit and extracting the top 10 bits from mantissaHigh :
558- mantissa = 0x400 | ( mantissaHigh >>> 10 ) ;
536+ // Create an 11-bit mantissa by adding the implicit leading 1 bit and extracting the top 10 bits from mantissa :
537+ mantissa = ( 0x800000 | mant ) >>> 13 ;
559538
560539 // Determine the round bit and sticky bits based on the shift amount to apply correct rounding:
561540 if ( shift < 11 ) {
@@ -565,16 +544,16 @@ <h1><a href="index.html">All files</a> main.js</h1>
565544 // Check if any bits below the round bit position are set (sticky bits):
566545 stickyBits = ( mantissa & ( ( 1 << ( shift - 1 ) ) - 1 ) ) !== 0;
567546
568- // If no sticky bits found in the 11-bit mantissa, check the remaining bits from the original float64 mantissa:
547+ // If no sticky bits found in the 11-bit mantissa, check the remaining bits from the original mantissa:
569548 if ( !stickyBits ) {
570- stickyBits = ( ( mantissaHigh & 0x3FF ) !== 0 ) || ( mantissaLow !== 0 ); // eslint-disable-line max-len
549+ stickyBits = ( mant & 0x1FFF ) !== 0;
571550 }
572551 }< span class ="branch-0 cbranch-no " title ="branch not covered " > else {</ span >
573- < span class ="cstat-no " title ="statement not covered " > // When the shift is 11 or greater, the round bit comes from the lower bits of mantissaHigh: </ span >
574- < span class ="cstat-no " title ="statement not covered " > roundBit = ( mantissaHigh >>> ( 10 - ( shift - 11 ) - 1 ) ) & 1;</ span >
552+ < span class ="cstat-no " title ="statement not covered " > // When the shift is 11 or greater, the round bit comes from original mantissa </ span >
553+ < span class ="cstat-no " title ="statement not covered " > roundBit = ( mant >>> ( 13 - ( shift - 11 ) - 1 ) ) & 1;</ span >
575554< span class ="cstat-no " title ="statement not covered " > </ span >
576- < span class ="cstat-no " title ="statement not covered " > // Check if any bits below the round bit position in mantissaHigh or any bits in mantissaLow are set:</ span >
577- < span class ="cstat-no " title ="statement not covered " > stickyBits = ( ( mantissaHigh & ( ( 1 << ( 10 - ( shift - 11 ) - 1 ) ) - 1 ) ) !== 0 ) || ( mantissaLow !== 0 ) ; // eslint-disable-line max-len</ span >
555+ < span class ="cstat-no " title ="statement not covered " > // Check if any bits below the round bit position in mantissa are set:</ span >
556+ < span class ="cstat-no " title ="statement not covered " > stickyBits = ( mant & ( ( 1 << ( 13 - ( shift - 11 ) - 1 ) ) - 1 ) ) !== 0; // eslint-disable-line max-len</ span >
578557< span class ="cstat-no " title ="statement not covered " > }</ span >
579558
580559 // Apply the denormalization shift to the mantissa:
@@ -588,14 +567,14 @@ <h1><a href="index.html">All files</a> main.js</h1>
588567 return ( sign << 15 ) | mantissa;
589568 }
590569
591- // Extract the top 10 bits of the mantissa for normal float16 representation:
592- mantissa = mantissaHigh >>> 10 ;
570+ // Extract the top 10 bits of the mantissa from 23 bits
571+ mantissa = mant >>> 13 ;
593572
594573 // Extract the round bit (the first bit that will be truncated):
595- roundBit = ( mantissaHigh >>> 9 ) & 1;
574+ roundBit = ( mant >>> 12 ) & 1;
596575
597- // Check sticky bits (all bits below bit 41 )
598- stickyBits = ( ( mantissaHigh & 0x1FF ) !== 0 ) || ( mantissaLow !== 0 ) ;
576+ // Check sticky bits (all bits below bit 12 )
577+ stickyBits = ( mant & 0xFFF ) !== 0;
599578
600579 // Round up if roundBit is 1 AND (sticky bits OR mantissa is odd)
601580 if ( roundBit && ( stickyBits < span class ="branch-0 cbranch-no " title ="branch not covered " > || ( mantissa & 1 ) </ span > ) ) {
@@ -631,7 +610,7 @@ <h1><a href="index.html">All files</a> main.js</h1>
631610 < div class ='footer quiet pad2 space-top1 center small '>
632611 Code coverage generated by
633612 < a href ="https://istanbul.js.org/ " target ="_blank " rel ="noopener noreferrer "> istanbul</ a >
634- at 2025-11-27T10:10:54.218Z
613+ at 2025-12-02T09:11:57.970Z
635614 </ div >
636615 < script src ="prettify.js "> </ script >
637616 < script >
0 commit comments