Skip to content

instance equality - trailing zeroes are insignificant? #221

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

Closed
asgs opened this issue Jan 4, 2017 · 14 comments
Closed

instance equality - trailing zeroes are insignificant? #221

asgs opened this issue Jan 4, 2017 · 14 comments
Assignees
Labels
clarification Items that need to be clarified in the specification core Priority: Low question
Milestone

Comments

@asgs
Copy link
Contributor

asgs commented Jan 4, 2017

Hello! The spec says that trailing zeroes are insignificant when it comes to instance equality.

Was it meant as leading zeroes instead? Also, I'm assuming this is referring to the fields of type "number". Please clarify.

@Relequestual
Copy link
Member

That's actually a really good point... No idea how that skipped through the net. I believe you are correct.

@awwright @handrews could either of you confirm this?

@Relequestual
Copy link
Member

The intention may have been trailing zeroes AFTER the decimal place, but I agree it's somewhat ambigious.

@awwright
Copy link
Member

awwright commented Jan 4, 2017 via email

@Relequestual
Copy link
Member

OK. I'll self assign to make a PR on this one.

@awwright
Copy link
Member

awwright commented Jan 4, 2017 via email

@handrews
Copy link
Contributor

handrews commented Jan 5, 2017

This just intends to say that differences in trailing zeros do not impact equality because they are not mathematically significant, right? 1, 1.0, and 1.00000 are all mathematically equivalent, so as instances they are equal. This is different from JSON equality as discussed in RFC 7159 which just discusses equality in terms of encoded strings.

@awwright
Copy link
Member

awwright commented Jan 5, 2017 via email

@handrews
Copy link
Contributor

handrews commented Jan 5, 2017

@awwright I don't think that JSON Schema needs to clutter itself with explanations that 10 and 100 are different numbers.

@awwright
Copy link
Member

awwright commented Jan 5, 2017 via email

@awwright
Copy link
Member

awwright commented Feb 1, 2017

Can we just say "excess zeros" here instead?

@seagreen
Copy link
Collaborator

seagreen commented Feb 6, 2017

Here's some examples as I understand the concern and behavior of JSON:
...
1.0==1.00

This is incorrect. A JSON text is a series of tokens. 1.0 and 1.00 are clearly different series of tokens.

@awwright
Copy link
Member

awwright commented Feb 6, 2017

@seagreen That seems to be a different understanding, of the sense that they will be different lexical representations (and different information resources/documents), but not necessarily different values. The value space of JSON is sort of implied in RFC 7159, as in this passage among others:

Implementations that transform the
textual representation into sequences of Unicode code units and then
perform the comparison numerically, code unit by code unit, are
interoperable in the sense that implementations will agree in all
cases on equality or inequality of two strings. For example,
implementations that compare strings with escaped characters
unconverted may incorrectly find that "a\b" and "a\u005Cb" are not
equal.

JSON Schema specifically defines a data model that JSON values are computed by, however see #152 for an idea on exposing the precision of a number for applications that need to distinguish between 1 and 1.0000 (like engineering applications).

@seagreen
Copy link
Collaborator

seagreen commented Feb 7, 2017

Right, JSON Schema works on a different data model than plain JSON.

I just wanted to be clear that there's nothing in JSON that says 1.0 == 1.00. JSON specifies a lexical representation in which those sequences of tokens aren't equal. It also clearly expects that in-memory representations of JSON will sometimes be compared (as is discussed in your excerpt about comparing strings) but doesn't say how this comparison should be done for numbers.

Sorry if this seems nitpicky, but I think it's important to be precise on what JSON is, what JSON Schema is, and the boundaries between them.

@handrews
Copy link
Contributor

I think #455 addresses this sufficiently, please re-open if not.

@ghost ghost removed the Status: Available label Oct 28, 2017
@gregsdennis gregsdennis added clarification Items that need to be clarified in the specification and removed Type: Maintenance labels Jul 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clarification Items that need to be clarified in the specification core Priority: Low question
Projects
None yet
Development

No branches or pull requests

6 participants