Add integer-only versions of rounding functions #243
Labels
⬇️ affects: code (interfaces)
Affects the way end users will interact with the library
📁 kind: enhancement
New feature or request
💪 effort: medium
Right now, all of our rounding functions (the
round
,floor
, andceil
families) are designed as "unit-aware" analogues of their standard library counterparts. This has the galling consequence that for people working with pure integer types, even though the final result will also be an integer, we need to take a detour through the floating point domain, because that is what the standard library functions do!It feels like we could do way better, with an approach that Au makes possible which I've never seen before. We should be able to generate rounding functions that live purely inside of the integral domain. For example, we could generate a unit that is half the target unit, add "1" in this unit, and truncate the result. We'd need a bunch of test cases, but this could be really useful (especially for embedded code).
The text was updated successfully, but these errors were encountered: