core-wg / yang-cbor

Internet-Draft for CBOR representation of YANG data
5 stars 10 forks source link

Correctly use quotes for uint64 in .sid example (via Jernej Tuljak) #150

Closed cabo closed 1 year ago

cabo commented 1 year ago

Close #149

mcr commented 1 year ago

I tried to follow the issue conversation. As I understand it, we have to quote things because not every JSON implementation supports the full range of the uint64, and might turn it into an int64?

abierman commented 1 year ago

The JSON standard uses 56 bit numbers I think. The 64 bit YANG types must be encoded as a string in JSON.

core-bot commented 1 year ago

On 2023-02-24, at 19:06, Michael Richardson @.***> wrote:

I tried to follow the issue conversation. As I understand it, we have to quote things because not every JSON implementation supports the full range of the uint64, and might turn it into an int64?

Full explanation in I-JSON, RFC7493

Short form: JSON uses a number system that is not further specified (like so many things in JSON). Many implementations use IEEE 754 binary64 for all numbers, which has 53 bits of precision. Numbers ≥ 2**53 lose their lower order bits on these implementations, so they are not interoperable where exact numbers are required (which is clearly true for YANG-SIDs).

So YANG-JSON (RFC 7951) decided to pack int64 and uint64 as decimal numbers into text strings. We have to follow.

By the way, YANG-SIDs are 63-bit integers (0..9223372036854775807). There is no confusion between int64 and uint64, as this information comes out of the YANG model.

Grüße, Carsten