Go back to Richel Bilderbeek's homepage.
Go back to Richel Bilderbeek's C++ page.
std::abs is an STL function to take the absolute value of a number (both int and double).
std::abs is defined in the header files cmath.h (for doubles) and cstdlib.h (for integers).
#include <cassert> |
#include <cassert> |
std::abs can be used to calculate the absolute value of both an integer and a double, where std::fabs can only be used to obtain the absolute value of a double.
Go back to Richel Bilderbeek's C++ page.
Go back to Richel Bilderbeek's homepage.