Split Number into Fractional and Exponent of 2 Parts
Breaks the number x
into its binary significand
(“fraction”) d in [0.5, 1)
and ex, the integral exponent for 2, such that
x = d * 2 ^ ex.
If x
is zero, both parts (significand and exponent) are zero.
frexpZ(x)
x |
integer or big integer ( |
a list
with the two components
d |
a numeric vector whose absolute values are either zero, or in [0.5, 1). |
exp |
an integer vector of the same length;
note that |
Martin Maechler
frexpZ(1:10) ## and confirm : with(frexpZ(1:10), d * 2^exp) x <- rpois(1000, lambda=100) * (1 + rpois(1000, lambda=16)) X <- as.bigz(x) stopifnot(all.equal(x, with(frexpZ(x), d* 2^exp)), 1+floor(log2(x)) == (fx <- frexpZ(x)$exp), fx == frexpZ(X)$exp, 1+floor(log2(X)) == fx )
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.