unpack-bits ( value -- e2 m2 acceptBounds ieeeExponent<=1? neg? string/f )


Vocabulary
ryu.private

Inputs
valuean object


Outputs
e2an object
m2an object
acceptBoundsan object
ieeeExponent<=1?an object
neg?an object
string/fan object


Definition


:: 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