Handbook
Glossary
ldexp ( x exp -- y )
Vocabulary
math
.
functions
Inputs
x
a
number
exp
a
number
Outputs
y
a
number
Word description
Multiply
x
by
2^exp
.
Notes
ldexp
is the inverse of
frexp
.
Definition
IN:
math.functions
GENERIC#:
ldexp
1
( x exp -- y )
Methods
USING:
combinators
kernel
math
math.functions
;
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
;
USING:
kernel
math
math.functions
;
M:
integer
ldexp
2dup
[
zero?
]
either?
[
2drop
0
]
[
shift
]
if
;