this post was submitted on 25 Jun 2023
1 points (100.0% liked)
Programmer Humor
19471 readers
1225 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
- Keep content in english
- No advertisements
- Posts must be related to programming or programmer topics
founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
Had to think about it, but yeah, I guess, you can't do division or non-integer multiplication with integer cents, as standard integer math always rounds downwards and it forces you to round after every step.
You could convert to a float for the division/multiplication and you do get more efficient addition/subtraction as well as simpler de-/serialization, but in most situations, it's probably less trouble to use decimals.