[R-SIG-Mac] Unexpected output from round()

Dennis Fisher fisher at plessthan.com
Sat Jun 13 02:39:29 CEST 2015


R 3.2.0
OS X

Colleagues

I received unexpected output from a command issued in a terminal window:

> dput(CI)
c(82.9888290534313, 100.544763749464)

> round(dput(CI), 2)
c(82.9888290534313, 100.544763749464)
[1]  82.98999999999999 100.54000000000001

I expected the result of the second command to be:
	82.99   100.54

Interesting, the problem also occurs if I round to 5 or 8 digits.  

Of note, the problem does NOT occur in R GUI or in Windows.

I am aware of FAQ 7.31 (Why doesn’t R think these numbers are equal?) but I don’t see how this could be manifestation of that issue.

I am curious as to the explanation of this issue.

Dennis


Dennis Fisher MD
P < (The "P Less Than" Company)
Phone: 1-866-PLessThan (1-866-753-7784)
Fax: 1-866-PLessThan (1-866-753-7784)
www.PLessThan.com



More information about the R-SIG-Mac mailing list