5 ms·
I find that many financial technology companies opt to store currency as strings. The small overhead is typically well worth freedom from floating-point errors.
by wyc 10y ago
I find that many financial technology companies opt to store currency as strings. The small overhead is typically well worth freedom from floating-point errors.
- Cshelton 10y agoCorrect. We store as strings then derive a number from the string for sorting purposes.
- deleted 10y ago[deleted]
- kazinator 10y agoAny text format is a technically a string. Just because some numeric token has no double quotes around it doesn't mean it isn't a string (in that representation). It's just that we can have some lexical rules that if that piece of text has the right kind of squiggly tail or whatever, it is always treated as a decimal float instead of every programmer working with it individually having to deal with an ad hoc string to decimal type conversion.
- kyllo 10y agoDon't they have to convert it back to a float to do math operations on it (if they're using JavaScript)?