Your language isn’t broken, it’s doing floating point math. Computers can only natively store integers, so they need some way of representing decimal numbers. This representation comes with some degree of inaccuracy. That’s why, more often than not, .1 + .2 != .3.

2 points

Why downvote? This is an often overlooked trap for programmers… especially those of the “data science” variety, but certainly not restricted to that subset.

permalink
report
reply
2 points

Exactly, well said.

permalink
report
reply

General Programming Discussion

!programming@lemmy.ml

Create post

A general programming discussion community.

Rules:

  1. Be civil.
  2. Please start discussions that spark conversation

Other communities

Systems

Functional Programming

Also related

Community stats

  • 146

    Monthly active users

  • 351

    Posts

  • 631

    Comments