-
Notifications
You must be signed in to change notification settings - Fork 12
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
Accessing the raw bytes or internal representation of a BUint/BInt #30
Comments
Hi @Lonsdaleiter, sorry for taking so long to reply to this... to access the underlying representation ( To access the raw bytes, it depends whether you want the bytes as a vector (without padding zeros) or as an array of the same byte size as the integer (with padding zeros):
Hopefully this is what you were looking for! |
@isaacholt100 Thanks so much for the patient reply! I don't know how I missed those functions they're pretty important. Relatedly, is there a reason why the BUint and BInt aren't marked |
Apologies for the late response again, it's been another busy week... to be honest, I think when I originally published bnum I wasn't aware of the different |
I found an official thread discussing what semver guidelines should be for repr changes: rust-lang/cargo#10276. This person makes the point (which I agree with) that going from So, I don't think it counts as a breaking change to change from default to transparent. I'm not aware of any downside |
I see, that makes sense. I think I might have read somewhere that adding |
I've read into this a bit more now, the struct isn't guaranteed to have the same layout as the single field unless it's marked as |
|
I'm trying to send a BInt to the GPU (I have an equivalent big two's complement integer structure there), but to do that I need to access the raw bytes of a BUint/BInt.
I've looked through the documentation and source of the project, but I can't find a way to access the raw bytes of a BUint/BInt. BUint is a wrapper around
[$Digit; N]
, but it isn't#[repr(transparent)]
, so I can't transmute BUint to the equivalent array. Is there no way to access the raw bytes or internal representation of either big integer type?The text was updated successfully, but these errors were encountered: