The cmath Header: pow sqrt abs round
Use the standard math library for common mathematical operations.
The <cmath> Header
Standard mathematical functions live in <cmath>. Most accept and return double; overloads for float and long double exist too.
Powers: pow
std::pow(base, exp) raises base to the power exp. Returns double.
#include <cmath>
double x = std::pow(2.0, 10); // 1024.0
double y = std::pow(9.0, 0.5); // 3.0All lessons in this course
- Integer vs Floating Point Types
- The cmath Header: pow sqrt abs round
- Random Numbers with the random Header
- Numeric Limits and Overflow Behaviour