No. I don’t have to remember that.
I just have to remember the limits and how you can break the system. You don’t have to think about the representation.
Comment on IEEE 754
zqwzzle@lemmy.ca 2 weeks agoIf you’re doing any work with accounting, or writing test cases with floating point values.
No. I don’t have to remember that.
I just have to remember the limits and how you can break the system. You don’t have to think about the representation.
tdawg@lemmy.world 2 weeks ago
Please tell me you aren’t using floating points with money
wewbull@feddit.uk 2 weeks ago
Knowing not to use floating point with money is good use of that knowledge.
psivchaz@reddthat.com 2 weeks ago
You’d be dismayed to find out how often I’ve seen people do that.
zqwzzle@lemmy.ca 2 weeks ago
Yeah I shudder when I see floats and currency.
Womble@lemmy.world 2 weeks ago
Eh, if you use doubles and you add 0.000314 (just over 0.03 cents) to ten billion dollars you have an error of 1/1000 of a cent, and thats a deliberately perverse transaction. Its not ideal but its not the waiting disaster that using single precision is.
SubArcticTundra@lemmy.ml 2 weeks ago
That sounds like an accident waiting to happen
Saleh@feddit.org 2 weeks ago
How do you do money? Especially with stuff like some prices having three or four decimals
jmcs@discuss.tchncs.de 2 weeks ago
Instead of representing $1.102 as
1.102
your store it as1012
(or whatever precision you need) and divide by 1000 only for displaying it.Saleh@feddit.org 2 weeks ago
So if you handle different precisions you also need to store the precision/exponent explicitly for every value. Or would you sanitise this at input and throw an exception if someone wants more precision than the program is made for?