float
Factor handbook » The language » Numbers » Floats

Next:>float ( x -- y )


Vocabulary
math

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

Definition


Methods








































M: float >base
{
{ [ over fp-nan? ] [ drop fp-sign "-0/0." "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 e^-1
dup abs 0.7 < [
dup e^ dup 1.0 =
[ drop ] [ [ 1.0 - * ] [ log / ] bi ] if
] [ e^ 1.0 - ] 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 ;