Skip to content

Instantly share code, notes, and snippets.

@samueltcsantos
Created May 20, 2017 23:44
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 samueltcsantos/d48a027bbd9e871f75cc103a95dcb0e4 to your computer and use it in GitHub Desktop.
Save samueltcsantos/d48a027bbd9e871f75cc103a95dcb0e4 to your computer and use it in GitHub Desktop.
Trying to do underflow and overflow in C language for the integer Type.
#include <stdio.h>
#include <limits.h>
int main(){
int maxValue = INT_MAX;
int minValue = INT_MIN;
int overflow = 0;
int underflow = 0;
printf("\nMin INT %d \n", minValue);
underflow = minValue - 1;
printf("Underflow is %d \n ", underflow);
printf("\nMax INT %d\n", maxValue);
overflow = maxValue + 1;
printf("Overflow INT %d \n ", overflow);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment