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

Support QuantityPoint in rounding functions #237

Merged
merged 2 commits into from
May 9, 2024
Merged

Conversation

chiphogg
Copy link
Contributor

@chiphogg chiphogg commented May 9, 2024

Includes the round, floor, and ceil families.

There's more subtlety here than for Quantity, because we can have
additive offsets. However, since these functions all aim to behave like
the standard library, and the standard library always uses floating
point, then it's actually quite simple. The way we handle rounding a
quantity point in different units than it's stored is to first perform
the conversion, then do the rounding. As with quantities, we use
RoundingRep to make sure we're using a sane floating point type to
perform the conversion.

Includes a bunch of new test cases, and doc updates.

Fixes #221.

Includes the `round`, `floor`, and `ceil` families.

There's more subtlety here than for `Quantity`, because we can have
additive offsets.  However, since these functions all aim to behave like
the standard library, and the standard library always uses floating
point, then it's actually quite simple.  The way we handle rounding a
quantity point in different units than it's stored is to first perform
the conversion, then do the rounding.  As with quantities, we use
`RoundingRep` to make sure we're using a sane floating point type to
perform the conversion.

Includes a bunch of new test cases, and doc updates.
@chiphogg chiphogg added the release notes: ✨ lib (enhancement) PR enhancing the library code label May 9, 2024
@chiphogg chiphogg requested a review from geoffviola May 9, 2024 15:34
@chiphogg chiphogg merged commit c08228a into main May 9, 2024
10 checks passed
@chiphogg chiphogg deleted the chiphogg/qp-round#221 branch May 9, 2024 16:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release notes: ✨ lib (enhancement) PR enhancing the library code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support QuantityPoint in math functions like round_in, round_as
2 participants