-
Notifications
You must be signed in to change notification settings - Fork 147
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
As (truncating) conversion for BigInt? #404
Comments
I understand the mathematical representation, but what would you actually use this for? |
Well, my case might not be particularly interesting to you since I'm implementing a programming language which has this as a primitive operation, but it also participates in some commuting diagrams like u64 multiplication being equal to bigint multiplication followed by a truncation (or more generally, any expression involving multiplication, addition, and subtraction on u64 with wrapping semantics is equal to the corresponding expression using entirely bigint types, followed by a truncation operation). It's useful to isolate the truncation part from the other operations. |
By the way, GMP's |
If you want to write this, I'm open. I think we can add this just in |
By a method, do you mean |
I might be missing it, but I don't see a version of
Wrapping<u32>
or other such wrapping conversions forBigInt
. Specifically, I would like to be able to convertn: BigInt
to(n % 2^N): uN
and(n + 2^(N-1)) % 2^N - 2^(N-1): iN
, which is what you would get withas
conversion, except thatBigInt
is not a primitive type so it doesn't have anAsPrimitive
implementation. Should this be a new trait, or a function?The text was updated successfully, but these errors were encountered: