-
Notifications
You must be signed in to change notification settings - Fork 246
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 functions for rounding rationals to integers #1585
Conversation
… rationals to integers
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the great PR! I've added a few minor comments about library style, feel free to check out the style guide for more detail.
On the more major questions side, these don't have any particularly fancy import requirements so I think they could probably go in Data.Rational.Base
?
It'd also be good to add their counter-parts to Data.Rational.Unnormalised
while you're here? As an aside that might help you prove some properties around them as well, as the standard proof style is first to prove properties of the unnormalised operations, then prove they're isomorphic to the normalised versions and then transfer the proofs across.
Can we add some test cases to https://github.com/agda/agda-stdlib/tree/master/tests/data |
Sure, that sounds like a good idea. Is there a guide on how to do this? I don't have any experience with that. |
Not really: it's a fairly new addition to the stdlib.
[1] They get run using the
and |
Side note: what should the fractional part of -3.7 be? I reckon 0.7. |
I'm sure there are coherent ways of making it 0.7, -0.7, 0.3 or -0.3. To me, it all depends on what relations with |
Yeah, there doesn't seem to be a convention, so I will redefine round p = round (- p)
fracPart p = fracPart (- p) |
@gallais I've put in the new test cases under |
Looks like you happen to have a trailing newline in your |
No, it appears that I didn't have a trailing newline, but now I've added one to match the other
EDIT: The checks all look fine now. |
Looks good! Thanks for the PR! |
Implements functions for rounding rationals to integers, thereby solving #1063.