Skip to content
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

support arbitrarily large integers #12

Open
michaelficarra opened this issue May 21, 2019 · 2 comments
Open

support arbitrarily large integers #12

michaelficarra opened this issue May 21, 2019 · 2 comments

Comments

@michaelficarra
Copy link
Member

michaelficarra commented May 21, 2019

Our current integers support magnitudes up to 264. Larger magnitudes will have to be encoded as floats/doubles or using binary* (losing the type info). Of course, this could be done via an extension point, but given the ubiquity of big integer libraries and especially with the addition of BigInt to JavaScript, I think built-in support might be worth it.

How could we do this? I recommend that we change uint64 to int64 (a signed 64-bit int) and replace nint64 with a VLQ. This would be a breaking change to the format.

edit: Alternatively, we could construct some sort of Rational representation using two VLQs.

edit again: I like git's "varint"s: https://github.com/git/git/blob/master/varint.c

@LewisJEllis
Copy link
Contributor

LewisJEllis commented May 23, 2019

I agree this seems like a worthwhile addition given the native addition of BigInt. VLQ and varint both seem like good options. What about using one of the reserved-but-unused type tags (0x80 or 0xF6) for this? I suppose it wouldn't create any backwards compatibility guarantee with old decoders (where we didn't define how they should treat reserved tags if encountered), but it would make new decoders compatible with old encoded data.

@michaelficarra
Copy link
Member Author

I messed around with a prototype this weekend: https://github.com/michaelficarra/varint-bigint

@LewisJEllis I'm not too concerned about spec stability yet. I'd rather choose the right assignments of the type tags. And if we have varints and int64, there's not much reason to have nint64.

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

No branches or pull requests

2 participants