frexp {accuracy}R Documentation

Function to convert vector of floating-point numbers to fractional and integral components

Description

The frexp() function returns a matrix with the normalized fraction [.5,1) of the vector in the first column and the exponent (a power of two) in the second column. (If x is zero, then the normalized fraction is zero and zero is stored in the exponent.)

Usage

        frexp(v)

Arguments

v vector of doubles

Details

This is an R wrapper around the <math.h> frexp() function.

Value

Returns a 2xn matrix. Thethe normalized fraction [.5,1) of x is the first column and the exponent (a power of two) in the second column. (If x[i] is zero, then the normalized fraction of x[i] is zero and zero is stored in the exponent.)

Author(s)

Micah Altman Micah_Altman@harvard.edu http://www.hmdc.harvard.edu/micah_altman/

References

Altman, M., J. Gill and M. P. McDonald. 2003. Numerical Issues in Statistical Computing for the Social Scientist. John Wiley & Sons. http://www.hmdc.harvard.edu/numerical_issues/

Examples

x = runif(10)
y = frexp(x)
y
# this is now true by construction
x==y[,1] *2^y[,2]


[Package accuracy version 1.31 Index]