Skip to content

Add caveat on numbers being represented as double #161

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 18, 2019
Merged

Conversation

gkellogg
Copy link
Member

if they're too large to represent as integers.

Co-Authored-By: gkellogg <[email protected]>
index.html Outdated
(<a>numbers</a> with a non-zero fractional part, i.e., the result of a modulo&#8209;1 operation,
<span class="changed">or which are too large to represent as integers,</span>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is important to specify what kind of integer this is (XSD, JSON, programming language integer, ...).
It looks like the XSD spec defines the value space of xsd:integer as an infinite set, which means that there is no maximum (or minimum) value.
Next to that, the JSON RFC also does not place a strict limit on integer/number sizes, but merely allows limits to be set by software.

Unless this has been defined somewhere already, I think it would be good to define integer sizes in the JSON-LD spec. To be consistent with most programming languages, values for 32-bit integer sizes may be useful. Perhaps this can be a soft limit, to be in line with JSON.

Side-note: Next to mentioning values that are too large, values that are too small should also be considered.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there such limit in the RDF model? I do not remember having one, in which case I do not think that, formally, JSON-LD could impose any limit...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Text was added to refer to Data Round Tripping for limitations on integer representations.

@gkellogg
Copy link
Member Author

This corresponds to w3c/json-ld-api#79, and is a practical consideration of round-tripping issues. In theory, JSON numbers can be of arbitrary length, but in practice, implementations use IEEE floating point representations for numbers (JS in particular, but also Ruby). Consequently, there is a limit to the size of an integer that JSON can represent with fidelity to be < 1e21.

However, it may be that we don't need to reflect such interoperability issues in the Syntax document.

@gkellogg gkellogg merged commit df7e8e0 into master Apr 18, 2019
@gkellogg gkellogg deleted the update-numbers branch April 18, 2019 21:02
@iherman iherman mentioned this pull request Oct 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants