ilogb | R Documentation |
Calculates logb(x, base=base) + eps
where eps
is a user-supplied (small) value and
converts the result ala as.integer
. The purpose of this function is to avoid
logb
variations between platforms. As an example, it is conceivable that logb(32, base=2)
on one platform could return a value of 5
while on another platform it could return a slightly smaller value,
e.g., 4.999999999999999
. The difference is due to different compiler and platform-specific implementations of
the S-PLUS or R languages. If logb
output is truncated (as is the case with as.integer(logb(x))
) then the
result may be unexpected, leading to intractable errors. By adding an appropriate and small value to logb(x)
,
subsequent truncation results in consistent value(s) across platforms.
ilogb(x, base=2, eps=.Machine$double.eps * 1e9)
x |
a numeric or complex vector. |
base |
a positive or complex number: the base with respect to which logarithms are computed. Default: |
eps |
a small numeric value that is added to the |
a numeric scalar or vector containing the result.
logScale
.
## should return 3 ilogb(8 - .Machine$double.eps, base=2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.