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

Add Int / Nat conversions #125

Merged
merged 4 commits into from
Jan 31, 2025
Merged

Add Int / Nat conversions #125

merged 4 commits into from
Jan 31, 2025

Conversation

rvanasa
Copy link
Collaborator

@rvanasa rvanasa commented Jan 29, 2025

This PR introduces Int.toNat(), Int.fromNat(), Nat.toInt(), and Nat.fromInt() to convert between integers and natural numbers. Because this is such a common use case, I think these conversions are worth including in both modules for convenience.

In addition, I added Int.fromText() which works in the same way as Nat.fromText() with an optional + or - symbol at the beginning of the input text.

Progress for #95.

@rvanasa rvanasa requested a review from a team as a code owner January 29, 2025 23:54
Copy link

github-actions bot commented Jan 29, 2025

No description provided.

crusso
crusso previously approved these changes Jan 30, 2025
Copy link
Contributor

@crusso crusso left a comment

Choose a reason for hiding this comment

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

LGTM!

@rvanasa rvanasa enabled auto-merge (squash) January 30, 2025 18:49
@crusso crusso requested review from crusso January 31, 2025 09:51
Copy link
Contributor

@crusso crusso left a comment

Choose a reason for hiding this comment

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

Sorry for the delay, didn't see the request. fromText i s another operation we might want to move to the RTS for speed... but can definitely come later...

@rvanasa rvanasa merged commit d1928b3 into main Jan 31, 2025
6 checks passed
@rvanasa rvanasa deleted the int-nat-conversions branch January 31, 2025 09:53
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.

2 participants