abhi9u@lemmy.world to Technology@lemmy.worldEnglish · 6 months agoHow Python Compares Floats and Ints: When Equals Isn’t Really Equalblog.codingconfessions.comexternal-linkmessage-square36fedilinkarrow-up11arrow-down10
arrow-up11arrow-down1external-linkHow Python Compares Floats and Ints: When Equals Isn’t Really Equalblog.codingconfessions.comabhi9u@lemmy.world to Technology@lemmy.worldEnglish · 6 months agomessage-square36fedilink
minus-squareBlackmist@feddit.uklinkfedilinkEnglisharrow-up0·edit-26 months agoI don’t think that’s how most programmers expect it to work at all. However most people would also expect 0.1+0.2==0.3 to return true, so what do I know. Floating point is something most of us ignore until it bites us in the ass. And then we never trust it again.
minus-square🇦🇺𝕄𝕦𝕟𝕥𝕖𝕕𝕔𝕣𝕠𝕔𝕕𝕚𝕝𝕖@lemm.eelinkfedilinkEnglisharrow-up0·6 months agoThats why i recon its good to keep u aware of it. Mind u i find its often fine as long as my ide and chagpt know what type it is im usually fine. I do kinda like the rigidity of types tho. Proper Python type hints are a godsend.
minus-squareMiaou@jlai.lulinkfedilinkEnglisharrow-up0·6 months agoThen most people shouldn’t be writing code, I don’t know what else to tell you, this is probably one of the first thing you learn about FP arithmetic, and any decent compiler/linter should warn you about that.
I don’t think that’s how most programmers expect it to work at all.
However most people would also expect 0.1+0.2==0.3 to return true, so what do I know.
Floating point is something most of us ignore until it bites us in the ass. And then we never trust it again.
Thats why i recon its good to keep u aware of it. Mind u i find its often fine as long as my ide and chagpt know what type it is im usually fine.
I do kinda like the rigidity of types tho. Proper Python type hints are a godsend.
Then most people shouldn’t be writing code, I don’t know what else to tell you, this is probably one of the first thing you learn about FP arithmetic, and any decent compiler/linter should warn you about that.