Error in reference description of abs

I didn't see a place to report errors on this site, so I'm posting my comment here.

http://www.cplusplus.com/reference/cmath/abs/
The page says
The additional overloads are provided in this header (<cmath>) for the integral types: These overloads effectively cast x to a double before calculations (defined for T being any integral type).

The second sentence is just plain wrong.

If you include just <cmath> or <math.h> and call abs with an integer value, you will get an error message about an ambiguous function call. If you want to take the absolute value of an integer value, you need to include <cstdlib> or <stdlib.h>, whether or not you include <cmath> or <math.h> to get the floating-point versions.

- Steve Clamage
Last edited on
At the bottom of every page there is a "Spotted an error? contact us" link. You have to scroll down pretty far to find it on the page you linked to.
Thanks! That link is in a really small font, hard to see. I submitted a comment.
¿you did do `std::abs()' right?
Yes. That is, I commented on the <cmath> abs.
The <cstdlib> abs is OK.
Last edited on
Topic archived. No new replies allowed.