• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Bit Shifting question

 
Ranch Hand
Posts: 834
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi, thank you for reading

i have a question which deal with bit shifting


x=1 ==> 0000 0000 0000 0000 0000 0000 0000 0001

my question is, let say right shift x to 31 bits, will the bit shift after the rightmost bit and then will continue the shift from leftmost ?

after right shift to 31 bits, would it be 0000 0000 0000 0000 0000 0000 0000 0010 ?
 
Ranch Hand
Posts: 1272
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

my question is, let say right shift x to 31 bits, will the bit shift after the rightmost bit and then will continue the shift from leftmost ?


You are describing a right circular shift. Java does not do this. Bits shifted past the end of a word go into the bit bucket, where they will be reused the next time you reboot your computer.
 
Alvin chew
Ranch Hand
Posts: 834
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
mike, thanks for answering , based on


can you please clarify further details? what do you means bit bucket ? and how could it be reuse during enxt time reboot the computer ?
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Alvin chew:
can you please clarify further details? what do you means bit bucket ? and how could it be reuse during enxt time reboot the computer ?



Alvin,

A "bit bucket" is slang for thrown away. A.K.A. "/dev/null", "round file", "trash can", etc...

Mike,

Maybe you should add a ... You never know when jokes may be taken seriously.

Henry
 
Alvin chew
Ranch Hand
Posts: 834
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sorry for misunderstanding
 
If you like strawberry rhubarb pie, try blueberry rhubarb (bluebarb) pie. And try this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic