int i=2147483647;
printf(“%d %d %d\n”,i,i+1,i+2);
output
2147483647 – 2147483648 -2147483647
is this the case of INTEGER OVERFLOW?? JUSTIFY…
int i=2147483647;
printf(“%d %d %d\n”,i,i+1,i+2);
output
2147483647 – 2147483648 -2147483647
is this the case of INTEGER OVERFLOW?? JUSTIFY…
EmbLogic Research & Competency Development Labs
Phone: +91 9818467776, 8527567776, 9650467776
Email: info@emblogic.com
Copyright © EmbLogic Embedded Technologies Pvt. Ltd.
Internally the compiler declare the integer variable as signed int hence the range of integer on 32 bit platform -2147483648 to 2147483647.
but how is it an overflow case..according to the compiler,
the values keep on repeating between (-)ve tp (+) range of signed..
overflow is nothing its warning to u if u r exceeding its value from upper range side….
int (Integer. ) size (4bytes) and range is
signed: -2147483648 to 2147483647
unsigned: 0 to 4294967295.
that,s why when it is 2147483647 then it will be printed same
but when it becomes 2147483648 the it will overflow and then it will move towars negative side and print -2147483648,,,and when it is
2147483649 then it will print -2147483647.and so on………..
it is something like this
-2147483648 to 0 to 2147483647
overflow means when its value is taken 2147483648 then compiler will take it as -2147473648.