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.