Skip to content

Conversation

@chiphogg
Copy link
Member

We introduce functions such as int_round_as as alternatives for every
function in the round_as family. The new functions use bespoke logic,
while the old ones wrap STL functions such as std::round. This gives
the new functions two advantages:

  1. They stay purely in the integer domain.
  2. They can support constexpr.

It feels goofy for an integer input to have to go through floating
point, and all of its weirdness at large values.

I've never seen anything like this before, probably because the notion
of "rounding" an integer type makes little sense in general: it's
already an integer. In the realm of unit conversions, though, we do
have applications for this.

Helps #243. A future PR will add "explicit Rep" versions of these.

We introduce functions such as `int_round_as` as alternatives for every
function in the `round_as` family.  The new functions use bespoke logic,
while the old ones wrap STL functions such as `std::round`.  This gives
the new functions two advantages:

1. They stay purely in the integer domain.
2. They can support `constexpr`.

It feels goofy for an integer input to have to go through floating
point, and all of its weirdness at large values.

I've never seen anything like this before, probably because the notion
of "rounding" an integer type makes little sense in general: it's
_already_ an integer.  In the realm of unit conversions, though, we do
have applications for this.

Helps #243.  A future PR will add "explicit Rep" versions of these.
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.

2 participants