Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.


Don't they have to convert it back to a float to do math operations on it (if they're using JavaScript)?


Correct. We store as strings then derive a number from the string for sorting purposes.


Any 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.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: