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.

24 lines
372 B

  1. #include <stdio.h>
  2. #include <limits.h>
  3. #include <float.h>
  4. int main (void) {
  5. int a = INT_MAX;
  6. float b = FLT_MAX;
  7. // overflow
  8. printf("Integer overflow: %d\n", a+1);
  9. printf("Float overflow: %f\n", b + 1.0);
  10. a = INT_MIN;
  11. b = -FLT_MAX;
  12. // underflow
  13. printf("Integer underflow: %d\n", a-1);
  14. printf("Float underflow: %f\n", b-1.0);
  15. return 0;
  16. }