EmbLogic's Blog

a query for int overflow

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…

5 Responses to a query for int overflow

  1. m siddarth says:

    Internally the compiler declare the integer variable as signed int hence the range of integer on 32 bit platform -2147483648 to 2147483647.

  2. overflow is nothing its warning to u if u r exceeding its value from upper range side….

  3. ashish.dahiya says:

    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………..

  4. ashish.dahiya says:

    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.

Leave a Reply to Kuldeep Dhanotia Cancel reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>