Learning by doing: Reading books and trying to understand the (code) examples
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

25 lines
372 B

#include <stdio.h>
#include <limits.h>
#include <float.h>
int main (void) {
int a = INT_MAX;
float b = FLT_MAX;
// overflow
printf("Integer overflow: %d\n", a+1);
printf("Float overflow: %f\n", b + 1.0);
a = INT_MIN;
b = -FLT_MAX;
// underflow
printf("Integer underflow: %d\n", a-1);
printf("Float underflow: %f\n", b-1.0);
return 0;
}