Can this be explained in context of numbers which are out of integer range ?

This can be explained by integer storage in computer and overflow due to limited range.

Remember that in computer negative integer is stored as the two's complement, ie. -x = (~x)+1.
(http://en.wikipedia.org/wiki/2%27s_complement)
Apply this to 0x80000000, we get: -0x80000000 = 0x7fffffff+1 = 0x80000000.
Note in the last addition, overlap occurs (from 2^31-1 to -2^32)

On 2010-8-31 7:45, Raj N wrote:
Can this be explained in context of numbers which are out of integer range ?

On Mon, Aug 30, 2010 at 10:36 PM, Yan Wang <wangyanadam1...@gmail.com <mailto:wangyanadam1...@gmail.com>> wrote:

    It's miracle can you explain?

    On Sun, Aug 29, 2010 at 8:07 PM, Terence <technic....@gmail.com
    <mailto:technic....@gmail.com>> wrote:
    >  Try this:
    >
    > int main()
    > {
    >  int data = (int)0x80000000; // Initialize data during run time
    >  if ( data == -data && data!=0)
    >    printf ("Miracle!!");
    > }
    >
    >
    > On 2010-8-28 1:45, Raj N wrote:
    >>
    >> int data; // Initialize data during run time
    >> if ( data == -data&&  data!=0)
    >>         printf ("Miracle!!");
    >>
    >> Will miracle ever print ?
    >>
    >
    > --
    > You received this message because you are subscribed to the
    Google Groups
    > "Algorithm Geeks" group.
    > To post to this group, send email to algogeeks@googlegroups.com
    <mailto:algogeeks@googlegroups.com>.
    > To unsubscribe from this group, send email to
    > algogeeks+unsubscr...@googlegroups.com
    <mailto:algogeeks%2bunsubscr...@googlegroups.com>.
    > For more options, visit this group at
    > http://groups.google.com/group/algogeeks?hl=en.
    >
    >

    --
    You received this message because you are subscribed to the Google
    Groups "Algorithm Geeks" group.
    To post to this group, send email to algogeeks@googlegroups.com
    <mailto:algogeeks@googlegroups.com>.
    To unsubscribe from this group, send email to
    algogeeks+unsubscr...@googlegroups.com
    <mailto:algogeeks%2bunsubscr...@googlegroups.com>.
    For more options, visit this group at
    http://groups.google.com/group/algogeeks?hl=en.


--
You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.

--
You received this message because you are subscribed to the Google Groups "Algorithm 
Geeks" group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to