This is from the JSON-LD spec.
-
This is from the JSON-LD spec.
ActivityPub / ActivityStream are based on JSON-LD.
I think it was a very bad idea for JSON-LD to define "number" this way!
It makes it so numbers with fractional values are inexact & lossy.
This include values that are common for money.
For example, neither 0.10 and 0.20 can be represented exactly. So, 0.10 + 0.20 does NOT equal 0.30!
It should have used FIXED-point numbers rather than FLOATING-point.
-
T tag-activitypub@relay.fedi.buzz shared this topic
-
This is from the JSON-LD spec.
ActivityPub / ActivityStream are based on JSON-LD.
I think it was a very bad idea for JSON-LD to define "number" this way!
It makes it so numbers with fractional values are inexact & lossy.
This include values that are common for money.
For example, neither 0.10 and 0.20 can be represented exactly. So, 0.10 + 0.20 does NOT equal 0.30!
It should have used FIXED-point numbers rather than FLOATING-point.
@reiver that's a json thing, which is itself a JavaScript thing. JS doesn't have an integer type, only number, which is a double precision floating point. Json is a serialization spec for JavaScript objects, and jsonld is spec for pretending that adding one property to a json document makes it a collection of rdf triples and then getting mad about it when the rest of the world just wants things to be parseable
-
@reiver that's a json thing, which is itself a JavaScript thing. JS doesn't have an integer type, only number, which is a double precision floating point. Json is a serialization spec for JavaScript objects, and jsonld is spec for pretending that adding one property to a json document makes it a collection of rdf triples and then getting mad about it when the rest of the world just wants things to be parseable
AFAIK, it is an IETF JSON thing, and wasn't part of the original (pre-IETF) JSON.
Here's the oldest version of the JSON spec I could find:
https://web.archive.org/web/20030228034147/http://www.crockford.com/JSON/index.html
It defines "number" as in the screen-shot, and doesn't say anything about floating-point numbers.
...
I do agree with you that the reason IETF JSON talked about floating-point numbers is almost certainly because of JavaScript.
-
This is from the JSON-LD spec.
ActivityPub / ActivityStream are based on JSON-LD.
I think it was a very bad idea for JSON-LD to define "number" this way!
It makes it so numbers with fractional values are inexact & lossy.
This include values that are common for money.
For example, neither 0.10 and 0.20 can be represented exactly. So, 0.10 + 0.20 does NOT equal 0.30!
It should have used FIXED-point numbers rather than FLOATING-point.
@reiver@mastodon.social pretty sure this kind of ambiguios why Stripe represents everything in cents, no?

-
Yes, very likely.
When I built the core software for a bank more than a decade ago, I did the same.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login