Skip to content

Simplify to_integer#145

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

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.
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