Created
August 20, 2015 17:48
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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