conspack/cl-conspack

Numbers larger than int128?

Opened this issue · 2 comments

(conspack:encode (1- (ash 1 128))) works,
but
(conspack:encode (ash 1 128)) fails.
Can cl-conspack support larger numbers?

rpav commented

There is bitspace for bignums I think, but they're not in the spec and not implemented.

This is not something I can do right now either, but if you want to figure it out and submit a PR let me know. The way things are looking, what you would want to do is use the #xE byte (let's call it "extended numbers" and leave #xD for long double), follow it by a new byte that looks like:

00xxxxnn

Leave the top two reserved, xxxx can be a new 4 type bits, and nn are size-encoding for stuff like bignum. However you'd encode it, it should be portable and easy to decode into any bignum system.

How's this for an encoding?
https://en.wikipedia.org/wiki/Variable-length_quantity
So #xE then 001011nn then variable-length-quantity-bytes
xxxx = #b1011 = #xB = "B" for "Bignum"