Replies: 1 comment 3 replies
-
What exactly is your use case? Storing such values in content items? With e.g. a |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
As OC stores data as json, there is basically no difference in storage between decimal, float and double. So the difference is made by the underlying model the json is deserialized to.
Is this correct?
But if I am using queries from db and use these in liquid templates, or I provide the json to the frontend, how is this to be handled properly?
To keep the precision of a decimal, frontend javascript would need to consume the json as a string and not as a number. This string could then be displayed as string, or assigned to a js implementation of decimal (I have found, but not tested this: https://github.com/MikeMcl/decimal.js).
Has there been put any thought into this already?
As a background for my question, you may check this:
https://stackoverflow.com/questions/3730019/why-not-use-double-or-float-to-represent-currency
Beta Was this translation helpful? Give feedback.
All reactions