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
- Keep content in english
- No advertisements
- Posts must be related to programming or programmer topics
founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
The example is wrong, because they used
1.0
.But in general
x-x
does not have to equal0
, that is true. I'm pretty sureNan
andinfinity
would yield not0.0
, butNan
instead.And if you reach x with two different calculations, e.g.
x1 = a - b - c
andx2 = a - c - b
it is certainly not guaranteed thatx1 - x2 == 0.0
This is correct. Additionally, if x is NaN, then x ≠ x.