This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • 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