News for hackers. Stuff that matters.
Re:What even is a JSON number? by Macha on Tuesday April 02, 2024 @06:59AM (#39904346)
Well I mean, if your minimal unit is 1c, then a price like $22.56 should be encoded as 2256 cents.

If you're doing ads and going for millicents, something like $0.01234 should be encoded as 1234 millicents.

Obviously you have to agree on what you're measuring in the API, you can't have some values be millicents and others cents.

Re:What even is a JSON number? by worddepress on Tuesday April 02, 2024 @07:07AM (#39904394)
Yeah I am more laughing that once encoded in JSON as { "p": 2256, "dp": 2 } you are using 2 floating point numbers. But JSON, and indeed JS wasn't designed.
Re:What even is a JSON number? by Macha on Tuesday April 02, 2024 @08:29AM (#39904949)
To be clear, I wasn't advocating for flexible decimal points. There is no "dp" parameter in the solution I was proposing. It's just documented in the API that "price" is denominated in cents (or satoshis or whatever you want)