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

[Feature request] Add support for i128 and u128 #594

Closed
Munksgaard opened this issue Feb 28, 2024 · 6 comments
Closed

[Feature request] Add support for i128 and u128 #594

Munksgaard opened this issue Feb 28, 2024 · 6 comments

Comments

@Munksgaard
Copy link

Munksgaard commented Feb 28, 2024

Since both Rust and Elixir have support for 128-bit sized integers (i128, u128, erlang) it seems natural that Rustler should support it as well.

I have a specific use case for i128s as well, which is implementing support for the Decimal type from Polars in Explorer.

@Munksgaard
Copy link
Author

I can't really figure out if this is going to be a problem, but at least it's something to be aware of.

@evnu
Copy link
Member

evnu commented Feb 28, 2024

Would this work for you: https://github.com/rusterlium/rustler/tree/master/rustler_bigint ?

@filmor
Copy link
Member

filmor commented Mar 9, 2024

I can't really figure out if this is going to be a problem, but at least it's something to be aware of.

I don't think this is relevant for Rustler. It would be, if the NIF API actually included (C-based) support for 128-bit integer types, but it only supports up to 64.

If someone wants to work on this, https://github.com/rusterlium/rustler/tree/master/rustler_bigint can be taken as a basis. While that library is more general and implements support for arbitrarily-sized integers, the same approach (going via the term_to_binary) can be used for the standard library types i128 and u128.

@Munksgaard
Copy link
Author

I have not had time to look at the bigint library yet, but it indeed seems like the easiest way to handle something like this.

@filmor
Copy link
Member

filmor commented Mar 12, 2024

Implemented in #600.

@filmor filmor closed this as completed Mar 12, 2024
@Munksgaard
Copy link
Author

Incredible! Thank you for your work @filmor!

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

3 participants