Namespaces
Variants
Views
Actions

Talk:cpp/numeric/math/abs

From cppreference.com

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 type X such that X(0) < X(-1) is true (which means on most platforms that X is of unsigned type) ...
or something similar. Space Mission (talk) 08:55, 6 November 2020 (PST)
std::abs can be called with an unsigned char arguments on most platforms, as unsigned char can be promoted to int. How about "an argument of integer type X such 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::abs is called with an unsigned argument and that cannot be converted to int by integral promotion, the program is ill-formed."
Or taking Space Mission's take into account, my proposed wording would be:
"If std::abs is called with an unsigned argument (that is, of arithmetic type X such that X(0) < X(-1) is true) that cannot be converted to int by integral promotion, the program is ill-formed."
I really just don't like the idea that std::abs would warrant any kind of complexity/verbosity/crypticism in its description. --Ybab321 (talk) 04:24, 8 November 2020 (PST)
I think your wording is better. Applied with redundant "integral" added. --Fruderica (talk) 01:35, 10 November 2020 (PST)
Much appreciated, thanks --Ybab321 (talk) 06:15, 11 November 2020 (PST)
1'd like to say the same . ) --Space Mission (talk) 08:28, 11 November 2020 (PST)