Skip to content

Simplify to_integer#145

Closed
mikem8891 wants to merge 1 commit intorust-num:masterfrom
mikem8891:to-integer
Closed

Simplify to_integer#145
mikem8891 wants to merge 1 commit intorust-num:masterfrom
mikem8891:to-integer

Conversation

@mikem8891
Copy link

The current code for to_integer calls trunc which calculates the integer then wraps it in a Ratio<T> then to_integer unwraps the numer that trunc returned. This pull request skips the extra steps.

This highlights some of the absurdity in that truc, round, floor, and ceil return integers wrapped in Ratio<T> instead of the underlying type T and for 3 of those functions (round, floor, and ceil) there are no functions provided to get the integers directly.

The current code for `to_integer` calls `trunc` which calculates the integer then wraps it in a `Ratio<T>` then `to_integer` unwraps the `numer` that `trunc` returned.  This commit skips the extra steps.
mikem8891 added a commit to mikem8891/num-rational that referenced this pull request Mar 13, 2026
@mikem8891
Copy link
Author

Superseded by #150

@mikem8891 mikem8891 closed this Mar 13, 2026
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.

1 participant