C++ Logo

std-proposals

Advanced search

[std-proposals] (Floating Idea) <intdiv> header for integer divisions

From: Jan Schultke <janschultke_at_[hidden]>
Date: Fri, 7 Apr 2023 11:34:10 +0200
 Integer divisions with different rounding modes than the division operator
(truncating rounding) are often useful. In the past, I've either emulated
them with floating point functions or implemented them from scratch each
time, but this is a feature which intuitively belongs in the standard
library.

I've made a rough draft of a proposal here:
https://gist.github.com/Eisenwave/2a7d7a4e74e99bbb513984107a6c63ef

The proposal adds 14 functions for obtaining the quotient and remainder of
integer divisions with different rounding modes. There's also a working
implementation for all of them, which still needs more testing but is most
likely correct since I've tested most of it in past projects.

Feedback is highly appreciated, I'm new here :)

Received on 2023-04-07 09:34:22