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
![](/static/devrant/img/pipeless-devrant-banner-white.png)
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
crisz82395yIt MUST be stored in string format. Currency has to be handled as string. I'm sorry, but you're the wrong one here
-
crisz82395yThe 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
-
crisz82395y@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
-
C0D4682465y@crisz but that's why we enforce 2 digit precision in other languages or do *100 scenario.
Adds useless complexity but it works. -
crisz82395y@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
-
arwinneil34
Just found the best dev ever. https://alcohollick.com/tfw.html
-
dfox81
As a long-time iPhone user, I am really sorry to say it but I think Apple has completed their transition to be...
-
rizasif9230
Apple 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