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

uint64 support (and bigger integers) #1345

Open
bettio opened this issue Oct 15, 2024 · 1 comment
Open

uint64 support (and bigger integers) #1345

bettio opened this issue Oct 15, 2024 · 1 comment

Comments

@bettio
Copy link
Collaborator

bettio commented Oct 15, 2024

A complete integer bignum implementation, with arbitrary integers, might take quite some flash space, so we may rather investigate support for "bigger integers".

Right now our biggest supported integer type is signed int64, that means we support up to UINT63_MAX, leaving out bigger positive integers such as values that can be represented with an uint64.

Rationale: uint64 is quite widespread in some serialization formats, such as protobuf and others, so it might tricky to handle that kind of values.

On the BEAM boxed integers already have a bit available for sign (001s BIGNUM with sign bit):

  1. should we use it for extending support up to 64 + sign bit?
  2. supporting wider integers such as 128 bit or 256 bit integers seems a reasonable amount of work. Should we support them (and keep one of them as new limit)?
  3. what is a reasonable limit for wider integers? (e.g. 512 bit integers seems quite uncommon)
  4. should we rather support uint64 as a wider signed integer?
  5. also, let's assume we are going to support a 256 bit integer, should we keep the sign bit out of it?

Also it is worth to be noted we don't need to support multiple bigger integer types, such as both 128 and 256 bit, we can just promote any >= 65 bit to the biggest one (such as the 256 bit integer).

This might be a good feature for v0.7.

@UncleGrumpy
Copy link
Collaborator

If we can easily extend support to 64-bit signed, that seems like a nice addition. Perhaps some testing on various supported hardware could help determine the largest BIGNUM to support. 512 does seem a bit much for microcontrollers.

Personally I think it would be better to support signed BIGNUM over size. If it comes down to 256 unsigned or 128 signed, I would opt for 128-bit signed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants