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

Implement floor, ceil and round #269

Merged
merged 1 commit into from
Feb 23, 2024
Merged

Implement floor, ceil and round #269

merged 1 commit into from
Feb 23, 2024

Conversation

frectonz
Copy link
Contributor

@frectonz frectonz commented Feb 15, 2024

Closes #155

I am not sure if converting BigRats into f64s and then doing the operations on them is the right way to implement this but this is what i was able to come up with. I am happy to modify the code based on any suggestions on how to do this better.

pub(crate) fn floor<I: Interrupt>(self, int: &I) -> FResult<Self> {
  let float = self.into_f64(int)?.floor();
  Self::from_f64(float, int)
}

pub(crate) fn ceil<I: Interrupt>(self, int: &I) -> FResult<Self> {
  let float = self.into_f64(int)?.ceil();
  Self::from_f64(float, int)
}

pub(crate) fn round<I: Interrupt>(self, int: &I) -> FResult<Self> {
  let float = self.into_f64(int)?.round();
  Self::from_f64(float, int)
}

Copy link

codecov bot commented Feb 15, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (fb02762) 83.20% compared to head (eda5977) 83.30%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #269      +/-   ##
==========================================
+ Coverage   83.20%   83.30%   +0.10%     
==========================================
  Files          52       52              
  Lines       14532    14623      +91     
==========================================
+ Hits        12091    12182      +91     
  Misses       2441     2441              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@printfn
Copy link
Owner

printfn commented Feb 23, 2024

Looks good, thanks!

@printfn printfn merged commit 3510d59 into printfn:main Feb 23, 2024
6 checks passed
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.

No floor/ceil/round functions
2 participants