today I'm thinking about the "don't use floating point for money" advice I hear all the time. It obviously has a lot of truth to it.

But -- Excel/Google Sheets uses floating point for all of its calculations, people use spreadsheets for money calculations all the time, and it generally seems to work just fine -- the results get rounded for display.

So I'm trying to figure out if there's a more nuanced guideline than "never use floating point for money".

@b0rk this is a really interesting and smart question.

@nelson @b0rk It depends on what you're doing. My father was an accountant for the phone company, and he'd worry about being pennies off in a billion-dollar figure. Errors of that size accumulate quickly with floating point. It's a problem (probably not a big one, but that's what accountants do) if it shows up on a corporate tax document. It's all about precision.

OTOH, if you're doing a sales projection, your audience really only cares about two (maybe three) significant digits.

@mikeloukides @nelson @b0rk the place I've seen this matter was a telecoms billing system that was written by someone who didn't know this. Lots and lots of very small amounts adding up. Bonus points for having the itemised listing showing the customer how the maths has gone wrong too.

@Emily_S @mikeloukides @nelson @b0rk hold it... wasn't that how Richard Pryor's character got rich in Superman 3?

https://youtu.be/N7JBXGkBoFc

Superman III — Richard Pryor — half cents and Ferrari scenes

YouTube