this post was submitted on 25 Jun 2023
10 points (100.0% liked)

Programmer Humor

19594 readers
785 users here now

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

founded 1 year ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[โ€“] Knusper@feddit.de 0 points 1 year ago (1 children)

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.

[โ€“] Hotzilla@sopuli.xyz -1 points 1 year ago

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.