frexpZ | R Documentation |
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 \cdot 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
|
exp |
an integer vector of the same length;
note that |
Martin Maechler
log2
, etc; for bigz
objects built on
(the C++ equivalent of) frexp()
, actually GMP's
‘mpz_get_d_2exp()’.
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
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.