C Language Standard Math

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Syntax

  • #include <math.h>
  • double pow(double x, double y);
  • float powf(float x, float y);
  • long double powl(long double x, long double y);

Remarks

  1. To link with math library use -lm with gcc flags.
  2. A portable program that needs to check for an error from a mathematical function should set errno to zero, and make the following call feclearexcept(FE_ALL_EXCEPT); before calling a mathematical function. Upon return from the mathematical function, if errno is nonzero, or the following call returns nonzero fetestexcept(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW); then an error occurred in the mathematical function. Read manpage of math_error for more information.


Got any C Language Question?