[R] R numeric string problem
gunter.berton at gene.com
Wed Aug 12 19:50:10 CEST 2009
You need to read up about finite precision arithmetic and floating point
representation. In brief, note that 2^64 requires 20 decimal digits, and
some bits in double precision must be given up to sign, exponent, etc.
leaving 53 bits for precision = 16 decimal digits. This is exactly the
number of digits in the numeric representation that "match" your string. All
other digits thereafter are essentially random numbers.
If you just need to keep the string as a string and not manipulate it as a
numeric, then read it in as a character variable, not a numeric. If you need
to manipulate it exactly as a numeric, check out Ryacas or some other
computer algebra package that is capable of infinite precision arithmetic.
Genentech Nonclinical Biostatisics
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On
Behalf Of Andrew C
Sent: Wednesday, August 12, 2009 9:44 AM
To: r-help at r-project.org
Subject: [R] R numeric string problem
I have a text (.dat) file, in which each row contains several long numeric
strings. One of the strings is 38 digits long, for example:
When I read in the data file, this string shows up as 3.200801e+36. To get
rid of the scientific notation, I used "options(scipen=999)." When I did
this, the scientific notation went away, but the numeric string was
incorrect. It showed as:
Why would the number be incorrect? All of the other strings within this row
View this message in context:
Sent from the R help mailing list archive at Nabble.com.
R-help at r-project.org mailing list
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
More information about the R-help