2

I'm sorry for asking this stupid kind of question, but I can't understand why double variables are not printed as double. It seems, that they are truncated to a max number of digits which seems to be variable. Here an example:

>(1234567890.123456789 -> x)
[1] 1234567890

Where is the decimal digits gone? In the RStudio Environment view the value of x is being displayed as 1234567890.123456. Why does the console output differs from the environment view, and why does it differ from the values I entered?

> (567890.12345678912345 -> x)
[1] 567890.1
> sprintf("%f", x)
[1] "567890.123457"

The .Machine settings for double are these

    > .Machine$double.xmin ; .Machine$double.xmax
[1] 2.225074e-308
[1] 1.797693e+308

and here the complete list of the .Machine content

as.data.frame(.Machine) double.eps double.neg.eps double.xmin double.xmax double.base double.digits double.rounding double.guard 1 2.220446e-16 1.110223e-16 2.225074e-308 1.797693e+308 2 53 5 0 double.ulp.digits double.neg.ulp.digits double.exponent double.min.exp double.max.exp integer.max sizeof.long 1 -52 -53 11 -1022 1024 2147483647 4 sizeof.longlong sizeof.longdouble sizeof.pointer 1 8 16

Thanks for any support Wasili


Thanks

options(digits=20)

helped

laiki
  • 39
  • 4

0 Answers0