The result of 1 << 32

R

Randy Howard

tedu wrote
(in article
Are there real examples where it's not consistent? Buffer overruns
generally are, provided the data written is the same in all cases. I'm
curious to learn of any times when one time the daemons come out the
left nostril, and the next time the right, so to speak.

More typically, the same code, compiled on different platforms
(or compilers) will have different, often undesirable behavior.
It is also possible to have seemingly "random" behavior,
depending upon far too many items to characterize briefly.
Perhaps that is why it is "undefined" behavior? :)
 
B

Barry Schwarz

All,

Here is one question that I can not understand.

int main()
{
int i = 32;
printf("%p %p\n", 1<<i, 1<<32);

%p is the format for printing a void*, not for printing an int.
}

The result is:
0x1 0x0

("int" type on my machine is 32-bit)

Why 1<<i and 1<<32 get different result? I had thought
both of them would get 0x0.


<<Remove the del for email>>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,171
Messages
2,570,935
Members
47,472
Latest member
KarissaBor

Latest Threads

Top