Skip to content
Back to formatted view

Raw Message

Message-ID: <OFC39C017A.C6CA6424-ONC125759F.002D551B-C125759F.002DC317@precheza.cz>
Date: 2009-04-21T08:19:57Z
From: PIKAL Petr
Subject: bug when subtracting decimals?
In-Reply-To: <loom.20090421T075616-887@post.gmane.org>

r-help-bounces at r-project.org napsal dne 21.04.2009 10:00:06:

> Petr PIKAL <petr.pikal <at> precheza.cz> writes:
> 
> > Maybe that is because of Excel is so widespread now and gives expected 

> > results (it probably silently rounds all decimal numbers before 
> > calculation). 
> 
> Marc Schwartz already reminded me of that one, and it's a good point
> to explicitly mention in lectures. 
> 
> I suggest to extend R by introducing %==% as "being Excellently equal".

It helps but not in all cases

> (0.7-0.3)-.4>0
[1] FALSE
> (0.7-0.3)-.4<0
[1] TRUE
>

There always could be different issues with not exact representation of 
decimals. So educated user or internal rounding could help but I am not 
sure if later is desired.

Regards
Petr

> 
> Dieter
> 
> ______________________________________________
> 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.