Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
The word "anything" are spelt differently in the code and the output. ++ nonetheless
-
there are law rules to work with money. they allow to round floats in specific way.
-
inaba45897y@seraphimsystems because decimal numbers don't exist in computers and they operate with binary numbers. What some smart people have figured out is that you can cheat the computers to think its using decimal numbers,which occasionally leads to data loss, or gain as I think it is in this case
-
-
pain04861717yThat is why our legacy system (before using .net) always stored money in pennies as integers.
-
@inaba but you just work out the number as you would with binary and then apply a decimal at the right point? It doesn't seem so hard, maybe it wouldn't be fast but it should be pretty easy to emulate this in software...
-
@bahua I do think it's kind of silly that so many languages aren't handling it in smarter ways. Like having a fractional num type.
-
inaba45897y@seraphimsystems Decimal numbers in binary are a bit more complex for a good reason. Take 99 for instance, it's 1100011 in binary. If you had that as your decimal number and added .01 it wouldn't really overflow like you would expect it. You would just end up with .1 instead
Related Rants
-
CowboyBebop16"Don't give your 100%. Never. Once you gave, managers will start expecting more than that." - My mentor.
-
linuswillner15(Q: How much are you allowed to Google as a developer?) βYouβre allowed to Google as much as you want. Th...
-
ripbit18Never delete code immediately. Always comment it out first.
Try not to use floating point numbers in places where precision is important. Like for instance, money. Always store the base value where it makes the most sense
rant
wk103