Created
October 24, 2017 15:06
-
-
Save YulongNiu/f12d40a538e0c886b3ae3c74cb5c4ace to your computer and use it in GitHub Desktop.
Test the maximum and minimum int value in C99
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> | |
#include <limits.h> | |
#include <float.h> | |
int main() { | |
int a = INT_MIN; | |
int b = INT_MAX; | |
double c = DBL_MIN; | |
printf("min is %d and max is %d \n", a, b); | |
printf("min positive double is %ef \n", c); | |
// test cross limits | |
for (int i = 0; i < 10; ++i) { | |
printf("test %d cross min is %d and cross max is %d \n", i, a - 1, b + 1); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I tested it with codes:
and I get something different