Skip to content

Instantly share code, notes, and snippets.

@DavidEGrayson
Created August 20, 2015 17:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DavidEGrayson/a3f9df2c3445c6c8f003 to your computer and use it in GitHub Desktop.
Save DavidEGrayson/a3f9df2c3445c6c8f003 to your computer and use it in GitHub Desktop.
Woe unto any user that doesn't know that "pow" is a standard library function in C. The C standard allows this inconsistent behavior, sadly (Section 7.1.3 of N1124). I think C++ is better, at least based on how GCC behaves.
#include <stdio.h>
double pow(double x, double y)
{
return x + y;
}
int main()
{
volatile int y = 1;
printf("%f\n", pow(10, y)); // prints 11.000000
printf("%f\n", pow(10, 1)); // prints 10.000000
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment