• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

shift operators

 
Tom Graziose
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can someone clear this up for me.
Why is the result of "1 << 32" 1?
what happened to the x << y translates to x*2ey ???
 
Brett Knapik
Ranch Hand
Posts: 255
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
when you change those bits it makes the int value wrap around due to that you are making value bigger than an int can hold.
------------------
I wish there was a button on my monitor to turn up the intellegince.
Theres a button called 'brightness' but it doesn't work
 
Lahcen Mannou
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
The expression "1 << 32" is equivalent to "1 << (32%32)",
so because 32%32 = 0, the result is 1.
 
Tom Graziose
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Brett and Lahcen
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic