Converting hex format to float numbers in R -
could please me how can convert 4 byte hex format float number in r? example want transfer "aec7a042"
80.39
. not find in r after lots of search give me conversion! c function bitconverter. tosingle. need same in r? can me, please?
you can read value using readbin
. seems have 4-byte signed float value. can read with:
readbin("aec7a042", "double", size=4) # [1] 80.39
if doesn't work in version of r, try
x <- "aec7a042" readbin(as.raw(strtoi(substring(x, (step<-seq(1, nchar(x), by=2)), step+1), 16)), "double",n=1,size=4) # or readbin(as.raw(strtoi(apply(matrix(strsplit(x,"")[[1]],2),2,paste, collapse=""), 16)), "double", size=4)
here more explicitly convert character string raw vector of bytes.
Comments
Post a Comment