> On 23 Apr 2017, at 14:49 , J C Nash <profjcn...@gmail.com> wrote:
> 
> 
> So equality in floating point is not always "wrong", though it should be used
> with some attention to what is going on.
> 
> Apologies to those (e.g., Peter D.) who have heard this all before. I suspect
> there are many to whom it is new.

Peter D. still insists on never trusting exact equality, though. There was at 
least one case in the R sources where age-old code got itself into a condition 
where a residual terme that provably should decrease on every iteration 
oscillated between two values of 1-2 ulp in magnitude without ever reaching 0. 
The main thing is that you cannot trust optimising compilers these days. There 
is, e.g.,  no guarantee that a compiler will not transform

(x_new + offset) == (x_old + offset)

to

(x_new + offset) - (x_old + offset) == 0

to

(x_new - x_old) + (offset - offset) == 0

to.... well, you get the point.

-pd

-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Office: A 4.23
Email: pd....@cbs.dk  Priv: pda...@gmail.com

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.

Reply via email to