0 points

I know this is a humor subreddit and this is a joke, but this problem wasted a huge week of mine since I was dealing with absurdly small numbers in my simulations. Use fsum from math library in Python to solve this people.

permalink
report
reply
0 points

One of my lecturers mentioned a way they would get around this was to store all values as ints and then append a . two character before the final one.

permalink
report
parent
reply
0 points

Yeah, this works especially well for currencies (effectively doing all calculations in cents/pennies), as you do need perfect precision throughout the calculations, but the final results gets rounded to two-digit-precision anyways.

permalink
report
parent
reply
0 points

quite a horrible hack, most modern languages have decimal type that handles floating rounding. And if not, you should just use rounding functions to two digits with currency.

permalink
report
parent
reply

Programmer Humor

!programmer_humor@programming.dev

Create post

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

  • Keep content in english
  • No advertisements
  • Posts must be related to programming or programmer topics

Community stats

  • 3.3K

    Monthly active users

  • 806

    Posts

  • 12K

    Comments