C++ Logo

std-proposals

Advanced search

Re: [std-proposals] D3724 Integer division

From: Paul Caprioli <paul_at_[hidden]>
Date: Fri, 30 May 2025 16:00:19 +0000
>> No, that's not the confusion. Rouding towards positive or negative infinity >> (FE_UPWARDS, FE_DOWNARDS), towards zero (FE_TOWARDZERO) are readily >> understandable, and a "this is usually what you want" mode of FE_TONEAREST if >> possible would be the standard. I'm questioning the rest of them, which add to >> the complexity the and the unintuitiveness of API when a user tries to >> understand them, especially the distinction between nearest, odd, and even, or >> an "away from zero" one. > On a side note, my first ever contribution to the C++ draft was to > replace "rounded downwards" with "rounded towards negative infinity". > Some languages/documents use "down" to mean truncating, and some mean > flooring. It's garbage terminology. By comparison, none of the > proposed names are innately unclear like those modes. As even more of a side note, AVX512 allows floating-point rounding mode to be specified statically on a per-instruction basis. The following macros are defined: #define _MM_FROUND_TO_NEAREST_INT 0x00 #define _MM_FROUND_TO_NEG_INF 0x01 #define _MM_FROUND_TO_POS_INF 0x02 #define _MM_FROUND_TO_ZERO 0x03 #define _MM_FROUND_CUR_DIRECTION 0x04 Of course, floating point instructions don't round to the nearest INTeger, but that is the macro one is advised to use. See also: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117163 https://github.com/llvm/llvm-project/pull/99691

Received on 2025-05-30 16:00:25