This week's book giveaway is in the Design forum. We're giving away four copies of Building Microservices and have Sam Newman on-line! See this thread for details.

Unfortunately, bit shifting is part of the exam. I have never used bit shifting before. In all of the examples that I have seen (including the K&B book), it is assumed that you know what the bit pattern is for a given integer. .

My question: how are you supposed to know what the bit pattern is for an integer? Is there a formula for this? thnx, Nikki

Originally posted by Nikki Freeman: ...int i = 00000110; System.out.println(i); // = 72 not 6...

An integral literal that begins with zero is interpreted as octal (base 8). So 0110 is 64 + 8 = 72.

Similarly, hexadecimal (base 16) literals are prefixed with a zero and the letter 'x', using letters a-f to represent 10-15. For example, 0x1c represents 28.

You should expect bit questions on the 1.4 exam, so you should spend some time getting more comfortable with this.

"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer sscce.org