Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 476
  • Last Modified:

Decipher some code


I'm trying to learn Java and am working my way through some Java code and attempting to work out what it does before I compile it. So far, so good and, you guys have been a great help so far, but, I now need your help.

Consider these routines:

(a)     private void update(byte byte0)
          int i=(int)(count>>> 3 & 63L);
          count +=8L;
          if (i+63)

(b)     private int G(int i, int j, int k)
          return i & k | j & ~k;

1. Can any explain what count>>> 3 means?
2. What's the signficance of the "L" after the 63 and the 8?
3. In routine B what does the ~ signify before the k variable?

Class compiles OK so I guess that these are valid commands.

Any help please?

1 Solution
1. count>>> 3 : Right Shift bits of count to 3 position. For ex. if count bits are 101010, after
    count>>> 3 operation, count bits position will be 000101.
2. L stands for long (primitive) type. If you do not suffix with L,  default is int type.
3. ~ negation operator means  ~(01010),  will become 10101 .
>>1. Can any explain what count>>> 3 means?

The important thing here is that the operator '>>>' is an *un*signed right shift, as opposed to '>>' so if the original was negative, it will end up positive after shifting.
if you're just learning Java, digital signatures and encryption are kind of a "baptism by fire". Godspeed, Zaphod!
zaphod_beeblebroxAuthor Commented:
Thanks a million guys

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now