Vocabulary
math

Class description
The class of double-precision floating point numbers.

Definition

Methods

M: float >base
{
{ [ over fp-nan? ] [ 2drop "0/0." ] }
{ [ over 1/0. = ] [ 2drop "1/0." ] }
{ [ over -1/0. = ] [ 2drop "-1/0." ] }
{ [ over 0.0 fp-bitwise= ] [ 2drop "0.0" ] }
{ [ over -0.0 fp-bitwise= ] [ 2drop "-0.0" ] }
[ float>base ]
} cond ;

M: float frexp
dup fp-special? [ dup zero? ] unless*
[ 0 ] [
double>bits [
9227875636482146303 bitand 0.5 double>bits bitor
bits>double
] [ -52 shift 2047 bitand 1022 - ] bi
] if ; inline

M: float item>xml
number>string 1 nenum T{ xml-chunk
{ seq
V{
""
T{ tag { name ~name~ } { children ~vector~ } }
""
}
}
} interpolate-xml ;

M: float ldexp
over fp-special? [ over zero? ] unless*
[ drop ] [
[ double>bits dup -52 shift 2047 bitand 1023 - ] dip +
{
{ [ dup -1074 < ] [ drop 0 copysign ] }
{ [ dup 1023 > ] [ drop 0 < -1/0. 1/0. ? ] }
[
dup -1022 < [ 52 + -52 2^ ] [ 1 ] if
[ -9218868437227405313 bitand ]
[ 1023 + 52 shift bitor bits>double ] [ * ]
tri*
]
} cond
] if ;

M: float round-to-even
dup 0 > [
dup 4503599627370496.0 <=
[ 4503599627370496.0 + 4503599627370496.0 - ] when
] [
dup -4503599627370496.0 >=
[ 4503599627370496.0 - 4503599627370496.0 + ] when
] if ;