abhi9u@lemmy.world to Technology@lemmy.worldEnglish · 1 month agoHow Python Compares Floats and Ints: When Equals Isn’t Really Equalblog.codingconfessions.comexternal-linkmessage-square43fedilinkarrow-up1143arrow-down18
arrow-up1135arrow-down1external-linkHow Python Compares Floats and Ints: When Equals Isn’t Really Equalblog.codingconfessions.comabhi9u@lemmy.world to Technology@lemmy.worldEnglish · 1 month agomessage-square43fedilink
minus-squareSylvartas@lemmy.worldlinkfedilinkEnglisharrow-up4·1 month agoThat makes sense, but then you’d just have people converting the int to a float manually and run into the exact same issues.
minus-squaremuntedcrocodile@lemm.eelinkfedilinkEnglisharrow-up5·1 month agoI mean honestly its expected u should check floats similarity not equivalence.
minus-squareSylvartas@lemmy.worldlinkfedilinkEnglisharrow-up5arrow-down1·1 month agoAgreed. But the less experienced programmers I know are surprisingly naive about this.
minus-squaremuntedcrocodile@lemm.eelinkfedilinkEnglisharrow-up3·1 month agoYeah its gonna be one of those problems chatgpt ain’t gonna help
minus-squareMiaou@jlai.lulinkfedilinkEnglisharrow-up2·1 month agoThey wouldn’t be running into an issue, but creating one, that’s different
minus-squareSylvartas@lemmy.worldlinkfedilinkEnglisharrow-up1·1 month agoMeh. Imo anyone comparing an integer to a float and not expecting one of them to be implicitly casted to the other’s type will create that issue for themselves when doing the same thing with an explicit cast.
minus-squareMiaou@jlai.lulinkfedilinkEnglisharrow-up3·1 month agoWhat I meant is, the former can be a genuine mistake, the latter is a conscious (probably uneducated) decision
That makes sense, but then you’d just have people converting the int to a float manually and run into the exact same issues.
I mean honestly its expected u should check floats similarity not equivalence.
Agreed. But the less experienced programmers I know are surprisingly naive about this.
Yeah its gonna be one of those problems chatgpt ain’t gonna help
They wouldn’t be running into an issue, but creating one, that’s different
Meh. Imo anyone comparing an integer to a float and not expecting one of them to be implicitly casted to the other’s type will create that issue for themselves when doing the same thing with an explicit cast.
What I meant is, the former can be a genuine mistake, the latter is a conscious (probably uneducated) decision