this post was submitted on 30 Mar 2024
66 points (97.1% liked)

Programmer Humor

19593 readers
779 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 1 year ago
MODERATORS
 

Courtesy of @[email protected] though not sure if he's the original author of it.

you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 9 points 7 months ago* (last edited 7 months ago) (1 children)

The example is wrong, because they used 1.0.

But in general x-x does not have to equal 0, that is true. I'm pretty sure Nan and infinity would yield not 0.0, but Nan instead.

And if you reach x with two different calculations, e.g. x1 = a - b - c and x2 = a - c - b it is certainly not guaranteed that x1 - x2 == 0.0

[–] [email protected] 6 points 7 months ago

This is correct. Additionally, if x is NaN, then x ≠ x.