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
-
crisz82366yIt MUST be stored in string format. Currency has to be handled as string. I'm sorry, but you're the wrong one here
-
crisz82366yThe reason is easy, our calculators aren't good at handling decimals, and it can happen that 10.07 becomes 10.06. So you must handle them as string or, if you need to perform operations, multiply by 100 and handle them as int
-
@crisz or live in a country where there is no change, only integer currency values
-
crisz82366y@C0D4 IEEE 754 (floatint point arithmetic specification) can't handle decimals with precision. Every programming language that implements it, will be affected with the same problem
-
C0D4681386y@crisz but that's why we enforce 2 digit precision in other languages or do *100 scenario.
Adds useless complexity but it works. -
crisz82366y@oreru Not every implementation uses 52 bits. And by the way, precision decreases along with bigger integer parts
-
@crisz do you know the size of the integer you would need to not be accurate to 2 decimal points? More than your what your 32 bit Int arithmetic could handle. Store the damn thing as a Double and create an extension that returns a string when needed to display on UI. I guarantee OP’s lead did not have precision in mind when storing the property. He just wanted to make his job easier when displaying on the UI/too lazy to convert parsed JSON, assuming maybe the price comes in from API as a string. What was his justification OP?
Related Rants
-
arwinneil34Just found the best dev ever. https://alcohollick.com/tfw.html
-
dfox81As a long-time iPhone user, I am really sorry to say it but I think Apple has completed their transition to be...
-
rizasif9230Apple rejected my app, because they throught there was a frickin Windows phone on my loading screen. How inse...
The iOS team lead stored the price in string format.
devrant
team lead
ios