All is good [Software]

posted by Helmut Homepage – Vienna, Austria, 2020-12-11 00:36 (615 d 19:59 ago) – Posting: # 22137
Views: 6,258

Hi Ohlbe,

» … the same happens in [image]:

So you installed this goody at last? :-D

»

0==(0.5-0.4-0.1)
» [1] FALSE
» 0==(-0.4-0.1+0.5)
» [1] TRUE


» Are they first calculating -0.4-0.1=-0.5, which is nicely binarily coded, then -0.5+0.5=0 ?

Would have to dive into the lexer of the source of base-[image]. Likely not clever enough anyway. If you want to explore the matter, type ?Syntax, ?Arithmetic, ?Comparison, and their relatives. See also the (in)famous FAQ 7.31. However, the `==` operator should not be used to compare two objects for identity. Otherwise we fall into the binary trap:

x1 <- (0.5-0.4-0.1)
x2 <- (-0.4-0.1+0.5)
x1; x2
[1] -2.775558e-17
[1] 0

x1 == x2
[1] FALSE
identical(x1, x2)
[1] FALSE
all.equal(x1, x2)
[1] TRUE

Only the last function compares to the numeric precision of the machine* and this is what we want and the best we can hope for…



Dif-tor heh smusma 🖖 [image]
Helmut Schütz
[image]

The quality of responses received is directly proportional to the quality of the question asked. 🚮
Science Quotes

Complete thread:

UA Flag
Activity
 Admin contact
22,305 posts in 4,668 threads, 1,587 registered users;
online 7 (0 registered, 7 guests [including 5 identified bots]).
Forum time: Thursday 21:36 CEST (Europe/Vienna)

On two occasions I have been asked,—“Pray, Mr. Babbage,
if you put into the machine wrong figures,…
will the right answers come out?”
 …
I am not able rightly to apprehend the kind of confusion of ideas
that could provoke such a question.    Charles Babbage

The Bioequivalence and Bioavailability Forum is hosted by
BEBAC Ing. Helmut Schütz
HTML5