Namespaces
Variants
Views
Actions

Talk:cpp/language/operator arithmetic

From cppreference.com

There is a problem with your claims about floating point division by zero; I elaborated myself a little more at http://en.cppreference.com/w/Talk:cpp/language/types#Division_by_zero .

[edit] multiplicative operators doesn't address % operator

This discussion of multiplicative operators addresses division. That's fine. But the rules are different for operator % modulus. a % b generate compilation error if either a or b are not integral types. The standard does include fmod for such a purpose however

68.6.126.194 10:24, 2 March 2016 (PST)

the page does make that distinction currently, it defines * and / for "every pair of promoted arithmetic types", while it defines % for "every pair of promoted integral types". I agree that it is too standardesey and ought to repeat the point where the semantics of % are explained.. and now it does. --Cubbi (talk) 11:17, 2 March 2016 (PST)

[edit] This page doesn't note the fact that bit wise operations cannot be applied to floating point operands.

This page doesn't note the fact that bit wise operations cannot be applied to floating point operands.

From the standard

5.11 Bitwise AND operator [expr.bit.and] and-expression: equality-expression and-expression & equality-expression 1 The usual arithmetic conversions are performed; the result is the bitwise AND function of the operands. The operator applies only to integral or unscoped enumeration operands.

68.6.126.194 10:18, 15 January 2017 (PST)

this page says "For every pair of promoted integral types L and R"... Perhaps "integral types" and "arithmetic types" deserve some wikilinking.. or indeed better explanation. --Cubbi (talk) 11:13, 15 January 2017 (PST)
I think we should state it directly rather than rely on the built-in overload resolution signatures. After all, a floating point type is convertible to every (promoted) integral type; relying on the imaginary overload resolution being ambiguous is a bit too subtle for my taste. T. Canens (talk) 12:09, 15 January 2017 (PST)
Do you think the way it was done on the C side is better? I think I wrote that up with as a potentially better layout to what's here. --Cubbi (talk) 11:02, 5 February 2017 (PST)
Yes, I like that better. T. Canens (talk) 08:28, 7 February 2017 (PST)
Updated --Cubbi (talk) 08:02, 4 July 2017 (PDT)