abhi9u@lemmy.world to Technology@lemmy.worldEnglish · 1 month agoHow Python Compares Floats and Ints: When Equals Isn’t Really Equalblog.codingconfessions.comexternal-linkmessage-square34fedilinkarrow-up1107arrow-down15
arrow-up1102arrow-down1external-linkHow Python Compares Floats and Ints: When Equals Isn’t Really Equalblog.codingconfessions.comabhi9u@lemmy.world to Technology@lemmy.worldEnglish · 1 month agomessage-square34fedilink
minus-squareDark Arc@social.packetloss.gglinkfedilinkEnglisharrow-up14·edit-21 month agoComparing floats for equality is generally a bad idea anyways. Floats should really only be used for approximate math. You need something like Java’s BigDecimal or BigInteger to handle floating point math with precision. Looks like this is the equivalent for Python: https://docs.python.org/3/library/decimal.html
Comparing floats for equality is generally a bad idea anyways.
Floats should really only be used for approximate math. You need something like Java’s BigDecimal or BigInteger to handle floating point math with precision.
Looks like this is the equivalent for Python:
https://docs.python.org/3/library/decimal.html