I would like a pointer in the standard (n3242/3291/3290) about where it is defined that the remainder operator doesn't apply to floating point type.
The remainder operator %
is defined in 5.6.2
The binary / operator yields the quotient, and the binary % operator yields the remainder from the division of the first expression by the second. If the second operand of / or % is zero the behavior is undefined. For integral operands the / operator yields the algebraic quotient with any fractional part discarded if the quotient a/b is representable in the type of the result, (a/b)*b + a%b is equal to a.
I can't find where it is forbidden to use a floating point type. And the fact the standard explicitly treats integral operands
as a special case could be interpreted as: the operator exists for other non-integral types.
I know that MSVC and GCC doesn't accept it, and I looked at lots of answers about this issue, but I can't get a valid pointer in the C++ 11 standard.
C++11, 5.6/2:
The operands of
*
and/
shall have arithmetic or unscoped enumeration type; the operands of%
shall have integral or unscoped enumeration type. The usual arithmetic conversions are performed on the operands and determine the type of the result.
(Emphasis mine)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With