Skip to content

Conversation

@laurencelundblade
Copy link
Collaborator

These explain how big number unification affects the data model and how one might implement big numbers.

By this, a value like 0 or 1 encoded as major type 0 is clearly distinct from the same value encoded as tag 2.
However, text in {{Section 3.4.3 of -cbor}} overrides this and makes these values equivalent.
This text affects the CBOR data model.
No other serliazation requirement in {{-cbor}} or this document affects the data model.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
No other serliazation requirement in {{-cbor}} or this document affects the data model.
No other serialization requirement in {{-cbor}} or this document affects the data model.

However, text in {{Section 3.4.3 of -cbor}} overrides this and makes these values equivalent.
This text affects the CBOR data model.
No other serliazation requirement in {{-cbor}} or this document affects the data model.
Only this one.
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a sentence fragment. Please remove, or attach to the previous sentence.

That is, there is no data model in all of CBOR where these integer spaces are distinct.

It is not in the scope of this document to update the text of {{Section 3.4.3 of -cbor}}
This text is only describing a common assumption of the meaing the text in {{Section 3.4.3 of -cbor}}.
Copy link
Contributor

@rohanmahy rohanmahy Jan 21, 2026

Choose a reason for hiding this comment

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

Suggested change
This text is only describing a common assumption of the meaing the text in {{Section 3.4.3 of -cbor}}.
This text is only describing a common assumption of the meaning of the text in {{Section 3.4.3 of -cbor}}.


Some programming environments have good support for big numbers (e.g., Python, Ruby and Go) and some do not (e.g., C, C++ and Rust).
However, even in environments that support big numbers, support for native integer sizes (e.g., 64-bit integers) is much more efficient.
It is thus reasonable for a CBOR library to provide a separate API for handling native integers size from the one handling big numbers.
Copy link
Contributor

Choose a reason for hiding this comment

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

did you mean native-sized or just native?

Suggested change
It is thus reasonable for a CBOR library to provide a separate API for handling native integers size from the one handling big numbers.
It is thus reasonable for a CBOR library to provide a separate API for handling native-sized integers from the one handling big numbers.

However, even in environments that support big numbers, support for native integer sizes (e.g., 64-bit integers) is much more efficient.
It is thus reasonable for a CBOR library to provide a separate API for handling native integers size from the one handling big numbers.
When doing this, the big number API must encode the values in the range of major types 0 and 1 as major type 0 and 1, not tag 2 and 3.
Similar the decoding facilities handling big numbers must accept major types 0 and 1 even though it returns there values as big numbers.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Similar the decoding facilities handling big numbers must accept major types 0 and 1 even though it returns there values as big numbers.
Similarly, the decoding facilities handling big numbers must accept major types 0 and 1 even though those facilities present that range of values to the application as big numbers.

When doing this, the big number API must encode the values in the range of major types 0 and 1 as major type 0 and 1, not tag 2 and 3.
Similar the decoding facilities handling big numbers must accept major types 0 and 1 even though it returns there values as big numbers.

Alternately, some CBOR libraries may choose to return tags 2 and 3 in raw byte string form because this is very simple compared.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Alternately, some CBOR libraries may choose to return tags 2 and 3 in raw byte string form because this is very simple compared.
Alternately, some CBOR libraries may choose to return tags 2 and 3 in raw byte string form because this is very simple compared to implementing Big Numbers completely.

Alternately, some CBOR libraries may choose to return tags 2 and 3 in raw byte string form because this is very simple compared.
A full unified big number API incurs a few complications such as having to do big number increment and decrement by one for CBOR’s offset-by-one of negative values.
They also have to do the unification with major types 0 and 1.
Note also that major type 1 can express negative numbers beyond the range of native integers common and also have to be handled.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Note also that major type 1 can express negative numbers beyond the range of native integers common and also have to be handled.
Note also that major type 1 can express negative numbers well beyond the range of common native integers..

@laurencelundblade laurencelundblade merged commit 3d12333 into main Jan 25, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants