You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Splits a [double-precision floating-point number][ieee754] into a normalized fraction and an integer power of two.
35
+
Splits a [single-precision floating-point number][ieee754] into a normalized fraction and an integer power of two.
36
36
37
37
```javascript
38
-
var out =frexp( 4.0 );
38
+
var out =frexpf( 4.0 );
39
39
// returns [ 0.5, 3 ]
40
40
```
41
41
@@ -45,7 +45,7 @@ By default, the function returns the normalized fraction and the exponent as a t
45
45
var pow =require( '@stdlib/math/base/special/pow' );
46
46
47
47
var x =4.0;
48
-
var out =frexp( x );
48
+
var out =frexpf( x );
49
49
// returns [ 0.5, 3 ]
50
50
51
51
var frac = out[ 0 ];
@@ -58,35 +58,35 @@ var bool = ( x === frac * pow(2.0, exp) );
58
58
If provided positive or negative zero, `NaN`, or positive or negative `infinity`, the function returns a two-element `array` containing the input value and an exponent equal to `0`.
59
59
60
60
```javascript
61
-
var out =frexp( 0.0 );
61
+
var out =frexpf( 0.0 );
62
62
// returns [ 0.0, 0 ]
63
63
64
-
out =frexp( -0.0 );
64
+
out =frexpf( -0.0 );
65
65
// returns [ -0.0, 0 ]
66
66
67
-
out =frexp( NaN );
67
+
out =frexpf( NaN );
68
68
// returns [ NaN, 0 ]
69
69
70
-
out =frexp( Infinity );
70
+
out =frexpf( Infinity );
71
71
// returns [ Infinity, 0 ]
72
72
73
-
out =frexp( -Infinity );
73
+
out =frexpf( -Infinity );
74
74
// returns [ -Infinity, 0 ]
75
75
```
76
76
77
-
For all other numeric input values, the [absolute value][@stdlib/math/base/special/abs] of the normalized fraction resides on the interval `[0.5,1)`.
77
+
For all other numeric input values, the [absolute value][@stdlib/math/base/special/absf] of the normalized fraction resides on the interval `[0.5,1)`.
78
78
79
-
#### frexp.assign( x, out, stride, offset )
79
+
#### frexpf.assign( x, out, stride, offset )
80
80
81
-
Splits a [double-precision floating-point number][ieee754] into a normalized fraction and an integer power of two and assigns results to a provided output array.
81
+
Splits a [single-precision floating-point number][ieee754] into a normalized fraction and an integer power of two and assigns results to a provided output array.
- Care should be taken when reconstituting a [double-precision floating-point number][ieee754] from a normalized fraction and an exponent. For example,
103
+
- Care should be taken when reconstituting a [single-precision floating-point number][ieee754] from a normalized fraction and an exponent. For example,
104
104
105
105
```javascript
106
106
var pow =require( '@stdlib/math/base/special/pow' );
107
+
var f32 =require( '@stdlib/number/float64/base/to-float32' );
107
108
108
-
var x =8.988939926493918e+307; // x ~ 2^1023
109
+
var x =1.7014118346046923e+38; // x ~ 2^127
109
110
110
-
var out =frexp( x );
111
-
// returns [ 0.5000263811533315, 1024 ]
111
+
var out =frexpf( x );
112
+
// returns [ 0.5, 128 ]
112
113
113
114
// Naive reconstitution:
114
-
var y = out[ 0 ] *pow( 2.0, out[ 1 ] );
115
+
var y =f32( out[ 0 ] *f32( pow( 2.0, out[ 1 ] ) ) );
115
116
// returns Infinity
116
117
117
-
// Account for 2^1024 evaluating as infinity by recognizing 2^1024 = 2^1 * 2^1023:
- <span class="package-name">[`@stdlib/math/base/special/ldexp`][@stdlib/math/base/special/ldexp]</span><span class="delimiter">: </span><span class="description">multiply a double-precision floating-point number by an integer power of two.</span>
0 commit comments