bits>half ( bits -- float )


Vocabulary
math.floats.half

Inputs
bitsan object


Outputs
floatan object


Definition


: bits>half ( bits -- float )
[ -15 shift 31 shift ] [
32767 bitand dup zero? [
dup 31744 >=
[ 13 shift 2139095040 bitor ] [
dup 1024 < [
dup log2
[ nip 103 + 23 shift ]
[ 23 swap - shift 8388607 bitand ] 2bi bitor
] [ 13 shift 112 23 shift + ] if
] if
] unless
] bi bitor bits>float ;