[R] Converting IEEE Float in 16 char hex back to float

xlr82sas xlr82sas at aol.com
Sat Feb 27 06:43:43 CET 2010


Hi,

If I do the following

sprintf("%A",pi)
"0X1.921FB54442D18"

I have this 16 byte character string

hx<-"400921FB54442D18"

This is the exact hex16 representation of PI in
IEEE float that R uses in Intel 32bit(little endian) Windows
SAS uses the same representation. 11 bit exponent and 53 bit mantissa.

I want to do is recreate the float exactly from the 16 char hex

something like

MyPI<-readChar(hx,numeric(),16)

or in SAS

MyPI=input("400921FB54442D18",hex16.);
put MyPI=;

MYPI=3.1415926536

What I am trying to do is set up a lossless
transfer method from SAS to R

-- 
View this message in context: http://n4.nabble.com/Converting-IEEE-Float-in-16-char-hex-back-to-float-tp1571710p1571710.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list