On this page
pow
Prev: fabs | Up: math.h | Next: floor
Rel: math.h, math, time & assert Guide
Ref: cppreference — pow
Tags: #public #prog #c #stdlib #math #tier/standard
Include
#include <math.h>
Signature & Overview
double pow(double base, double exp);
Raises base to the power exp.
Notes & Pitfalls
- Avoid
pow(x, 2)for integer squares:x * xis faster and exact; negative bases with non-integer exponents yieldNaN.
Example
#include <assert.h>
#include <math.h>
int main(void) { assert(fabs(pow(2.0, 10.0) - 1024.0) < 1e-9); }
Linked from
Related notes
- tuts/c/stdlib/math/fabs Linked here; links to this page; shared tags: #c, #math, #prog, #stdlib, #tier
- tuts/c/stdlib/math/floor Linked here; links to this page; shared tags: #c, #math, #prog, #stdlib, #tier
- tuts/c/stdlib/math Linked here; links to this page; shared tags: #c, #math, #prog, #stdlib
- tuts/c/stdlib/math_time_and_assert Linked here; shared tags: #c, #prog, #stdlib
- tuts/c/stdlib/math/isnan shared tags: #c, #math, #prog, #stdlib, #tier
- tuts/c/stdlib/math/sqrt shared tags: #c, #math, #prog, #stdlib, #tier
- tuts/c/stdlib/assert/assert shared tags: #c, #prog, #stdlib, #tier
- tuts/c/stdlib/assert/static_assert shared tags: #c, #prog, #stdlib, #tier
- tuts/c/stdlib/ctype/isalpha shared tags: #c, #prog, #stdlib, #tier
- tuts/c/stdlib/ctype/isdigit shared tags: #c, #prog, #stdlib, #tier