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

More Integer conversions #1861

Merged
merged 9 commits into from
Sep 6, 2023
Merged

More Integer conversions #1861

merged 9 commits into from
Sep 6, 2023

Conversation

chipshort
Copy link
Collaborator

closes #1855

Added some missing From and TryFrom impl to convert between signed integers.

Copy link
Member

@webmaster128 webmaster128 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice. Let's give this a CHANGELOG entry

packages/std/src/math/conversion.rs Show resolved Hide resolved
packages/std/src/math/conversion.rs Show resolved Hide resolved
packages/std/src/math/conversion.rs Show resolved Hide resolved
packages/std/src/math/int128.rs Show resolved Hide resolved
packages/std/src/math/int64.rs Show resolved Hide resolved
output.copy_from_slice(&input[(INPUT_SIZE - OUTPUT_SIZE)..]);
Some(output)
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice to try to upstream those. I.e. go from BInt::<X> to BInt::<Y>. Then you can also operate in 8 steps which should be faster.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, after looking into this, there seems to already be a way of casting them using bnum's CastFrom or As trait, but it needs nightly features to be const.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright cool. This solution is good anyways. I just want to be nice and upstream ideas and code where possible.

@chipshort chipshort merged commit f20bc85 into main Sep 6, 2023
3 checks passed
@chipshort chipshort deleted the 1855-int-conversions branch September 6, 2023 07:43
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

Successfully merging this pull request may close these issues.

Missing signed int conversions
2 participants