💡𝚂𝗆𝖺𝗋𝗍𝗆𝖺𝗇 𝙰𝗉𝗉𝗌📱@programming.dev to Programmer Humor@programming.devEnglish · 8 months agoFloating point Mathsmessage-squaremessage-square7fedilinkarrow-up11arrow-down10file-text
arrow-up11arrow-down1message-squareFloating point Maths💡𝚂𝗆𝖺𝗋𝗍𝗆𝖺𝗇 𝙰𝗉𝗉𝗌📱@programming.dev to Programmer Humor@programming.devEnglish · 8 months agomessage-square7fedilinkfile-text
minus-squareTurun@feddit.delinkfedilinkarrow-up0·edit-28 months agoThe 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
minus-squaremokus@lemmy.blahaj.zonelinkfedilinkarrow-up1·8 months agoThis is correct. Additionally, if x is NaN, then x ≠ x.
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.