aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Bit Shifting question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Bit Shifting question " Watch "Bit Shifting question " New topic
Author

Bit Shifting question

Alvin chew
Ranch Hand

Joined: Jan 08, 2004
Posts: 834
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 ?
Mike Gershman
Ranch Hand

Joined: Mar 13, 2004
Posts: 1272
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.


Mike Gershman
SCJP 1.4, SCWCD in process
Alvin chew
Ranch Hand

Joined: Jan 08, 2004
Posts: 834
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 ?
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 19064
    
  40

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


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Alvin chew
Ranch Hand

Joined: Jan 08, 2004
Posts: 834
sorry for misunderstanding
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Bit Shifting question