Talk:cpp/numeric/math/abs
From cppreference.com
< Talk:cpp | numeric/math
Suggest we replace "argument of arithmetic type X such that X(0) < X(-1) is true and X" with "unsigned argument". Don't think there's risk of misinterpretation doing so. --Ybab321 (talk) 03:42, 6 November 2020 (PST)
- Or maybe use both:
... argument of arithmetic typeXsuch thatX(0) < X(-1)istrue(which means on most platforms thatXis ofunsignedtype) ...
- or something similar. Space Mission (talk) 08:55, 6 November 2020 (PST)
- std::abs can be called with an
unsigned chararguments on most platforms, asunsigned charcan be promoted toint. How about "an argument of integer typeXsuch that the type of+X()is an unsigned integer type"? --Fruderica (talk) 00:23, 7 November 2020 (PST)- I'm happy with the "cannot be converted to int by integral promotion" wording; I think banking on people knowing about unary + doing promotion is a little too cryptic. Full wording change would be like:
- "If
std::absis called with an unsigned argument and that cannot be converted tointby integral promotion, the program is ill-formed."
- "If
- Or taking Space Mission's take into account, my proposed wording would be:
- "If
std::absis called with an unsigned argument (that is, of arithmetic typeXsuch thatX(0) < X(-1)istrue) that cannot be converted tointby integral promotion, the program is ill-formed."
- "If
- I really just don't like the idea that
std::abswould warrant any kind of complexity/verbosity/crypticism in its description. --Ybab321 (talk) 04:24, 8 November 2020 (PST)
- I'm happy with the "cannot be converted to int by integral promotion" wording; I think banking on people knowing about unary + doing promotion is a little too cryptic. Full wording change would be like:
- std::abs can be called with an