Handbook
Glossary
unpack-bits ( value -- e2 m2 acceptBounds ieeeExponent<=1? neg? string/f )
Vocabulary
ryu
.
private
Inputs
value
an
object
Outputs
e2
an
object
m2
an
object
acceptBounds
an
object
ieeeExponent<=1?
an
object
neg?
an
object
string/f
an
object
Definition
USING:
kernel
math
math.bitwise
;
IN:
ryu.private
::
unpack-bits
( value -- e2 m2 acceptBounds ieeeExponent<=1? neg? string/f )
value
double>bits
dup
mantissaBits
exponentBits
+
bit?
:>
sign
dup
mantissaBits
bits
:>
ieeeMantissa
mantissaBits
neg
shift
exponentBits
bits
:>
ieeeExponent 0
:>
m2! 0
:>
e2!
exponentBits
on-bits
ieeeExponent
=
[
ieeeMantissa
zero?
[
sign
"-Inf"
"Inf"
?
]
[
"NaN"
]
if
]
[
ieeeExponent
[
ieeeMantissa
[
sign
"-0e0"
"0e0"
?
]
[
m2! -1
offset
-
mantissaBits
-
e2!
f
]
if-zero
]
[
offset
-
mantissaBits
-
2
-
e2! ieeeMantissa
mantissaBits
set-bit
m2!
f
]
if-zero
]
if
[
e2 m2
dup
even?
ieeeExponent 1
<=
sign
]
dip
;
inline