File tree Expand file tree Collapse file tree 1 file changed +9
-8
lines changed
lib/node_modules/@stdlib/math/base/special/exp2f/lib Expand file tree Collapse file tree 1 file changed +9
-8
lines changed Original file line number Diff line number Diff line change @@ -41,6 +41,7 @@ var FLOAT32_MIN_BASE2_EXPONENT = require( '@stdlib/constants/float32/min-base2-e
4141var roundf = require ( '@stdlib/math/base/special/roundf' ) ;
4242var ldexpf = require ( '@stdlib/math/base/special/ldexpf' ) ;
4343var isnanf = require ( '@stdlib/math/base/assert/is-nanf' ) ;
44+ var float64ToFloat32 = require ( '@stdlib/number/float64/base/to-float32' ) ;
4445var PINF = require ( '@stdlib/constants/float32/pinf' ) ;
4546var polyvalP = require ( './polyval_p.js' ) ;
4647var polyvalQ = require ( './polyval_q.js' ) ;
@@ -105,19 +106,19 @@ function exp2f( x ) {
105106 return PINF ;
106107 }
107108 if ( x < FLOAT32_MIN_BASE2_EXPONENT ) {
108- return 0.0 ;
109+ return float64ToFloat32 ( 0.0 ) ;
109110 }
110111 // Separate into integer and fractional parts...
111- n = roundf ( x ) ;
112- x -= n ;
112+ n = float64ToFloat32 ( roundf ( x ) ) ;
113+ x -= float64ToFloat32 ( n ) ;
113114
114- xx = x * x ;
115- px = x * polyvalP ( xx ) ;
116- x = px / ( polyvalQ ( xx ) - px ) ;
117- x = 1.0 + ldexpf ( x , 1 ) ;
115+ xx = float64ToFloat32 ( x * x ) ;
116+ px = float64ToFloat32 ( x * polyvalP ( xx ) ) ;
117+ x = float64ToFloat32 ( px / float64ToFloat32 ( ( polyvalQ ( xx ) - px ) ) ) ;
118+ x = float64ToFloat32 ( 1.0 ) + ldexpf ( x , 1 ) ;
118119
119120 // Scale by power of 2:
120- return ldexpf ( x , n ) ;
121+ return float64ToFloat32 ( ldexpf ( x , n ) ) ;
121122}
122123
123124
You can’t perform that action at this time.
0 commit comments