[R] strange floor rounding

Marc Schwartz marc_schwartz at me.com
Fri Jul 9 16:00:10 CEST 2010


On Jul 9, 2010, at 8:46 AM, Trafim Vanishek wrote:

> Dear all,
> 
> might seem and easy question but I cannot figure it out.
> 
> floor(100*(.58))
> [1] 57
> 
> where is the trick here? And how can I end up with the right answer?
> 
> Thanks a lot everybody for your help.
> Trafim


> sprintf("%.20f", 100 * .58)
[1] "57.99999999999999289457"


See R FAQ 7.31

HTH,

Marc Schwartz



More information about the R-help mailing list