Skip to content

Multiple fixes and added features#150

Open
mikem8891 wants to merge 1 commit into
rust-num:mainfrom
mikem8891:multi-fix
Open

Multiple fixes and added features#150
mikem8891 wants to merge 1 commit into
rust-num:mainfrom
mikem8891:multi-fix

Conversation

@mikem8891

@mikem8891 mikem8891 commented Mar 13, 2026

Copy link
Copy Markdown

In fn to_integer, I changed it to skip some extra steps. 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.

Added fn floor_to_int,ceil_to_int and round_to_int for #149. These are slightly simpler than the original versions and allow getting to the integer without the value being wrapped in a Ratio by the function and unwrapped by the user. Slight changes fix #143.

fn floor, ceil, and round were changed to use the *_to_int functions.

Added a remainder function and changed fract to use remainder

Added mixed to return &self as a mixed fraction (T, Ratio<T>)

In Inv::inv, I changed recip to into_recip to prevent a clone operation. This is in the spirit of #110.

Fixes #143 and closes #149 .

This PR supersedes #144 , #145 , #148 .

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.

Functions to return integers Floor and Ceil overflow too easily

1 participant