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

x
• Status: Solved
• Priority: Medium
• Security: Public
• Views: 476

# Decipher some code

Hi

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;
buffer[i]=byte0;
if (i+63)
transform(buffer,0);
}

(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.

Zaphod
0
zaphod_beeblebrox
1 Solution

Commented:
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 .
0

Commented:
>>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.
0

Commented:
if you're just learning Java, digital signatures and encryption are kind of a "baptism by fire". Godspeed, Zaphod!
0

Author Commented:
Thanks a million guys
0

## Featured Post

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