[R] operators %/% bug?

jim holtman jholtman at gmail.com
Mon Mar 31 18:14:40 CEST 2008


FAQ 7.31

a-b != 0.2

> a <- 1.2
>
> b <- 1.0
>
> a-b-.2
[1] -5.551115e-17
>



On 3/31/08, Lo, Ken <Ken.Lo at roswellpark.org> wrote:
> Dear  all,
>
>
>
> I have come across a strange behavior of the %/% operator, and I wasn't
> sure if this was intended.
>
>
>
> i.e.
>
> a <- 1.2
>
> b <- 1.0
>
> (a-b) %/% 0.1  results in 1?
>
> Whereas
>
> 0.2 %/% 0.1 results in 2.
>
>
>
> Am I missing something obvious here?  It seems to be consistent up to R
> 2.6.0 running in WinXP (haven't upgraded yet).
>
>
>
> Best,
>
>
>
> Ken
>
>
>
> This email message may contain legally privileged and/or confidential information.  If you are not the intended recipient(s), or the employee or agent responsible for the delivery of this message to the intended recipient(s), you are hereby notified that any disclosure, copying, distribution, or use of this email message is prohibited.  If you have received this message in error, please notify the sender immediately by e-mail and delete this email message from your computer. Thank you.
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>


-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem you are trying to solve?



More information about the R-help mailing list