# Bit Conversion

of converting decimal and octal numbers

to and from binary.

My exams is next saturday.

SCJA(Beta) SCJP 1.4 SCWCD 1.4 SCBCD 1.3 SCBCD 5.0 beta <br />The more practice we get, the better we are at the exams and in life in general. Pls join me at My DEN.

BigInteger is not a objective of the SCJP as far as i know.

Output is:

1001

1001

9

Good luck for your exams.

http://www.coderanch.com/t/248524/java-programmer-SCJP/certification/Bits-Conversion

If these didn't help, then what exactly are you looking for?

(BigInteger and BigDecimal are not on the SCJP 1.4 exam.)

"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

Result from my last post on this topic

was very helpful, i now know that in hex

0000 --> 0

so to get other simply add 1 to 0000

downwards.

i just need a similar formula

for oct and binary.

cheers

SCJA(Beta) SCJP 1.4 SCWCD 1.4 SCBCD 1.3 SCBCD 5.0 beta <br />The more practice we get, the better we are at the exams and in life in general. Pls join me at My DEN.

For example, decimal numbers use ten as a

*base.*This means that each digit represents a quantity multiplied by ten raised to some power. Specifically, the right digit is multiplied by 10^0, the digit to the left of that is multiplied by 10^1, the digit to the left of that is multiplied by 10^2, and so on.

So in base ten, 987 means (9 * 10^2) + (8 * 10^1) + (7 * 10^0).

In binary, the base is two, so 101 means (1 * 2^2) + (0 * 2^1) + (1 * 2^0).

In octal, the base is eight, so 765 means (7 * 8^2) + (6 * 8^1) + (5 * 8^0).

In hexadecimal, the base is 16 (with letters a-f used to represent 10-15), so c9a means (12 * 16^2) + (9 * 16^1) + (10 * 16^0).

With this understanding, do you see the patterns below?

"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

Thanks a million. Got to read your reply after

my exams. Well i passed with 77%, not quite happy with it

cause i made some silly errors.

Once thanks

SCJP 1.4

SCJA(Beta) SCJP 1.4 SCWCD 1.4 SCBCD 1.3 SCBCD 5.0 beta <br />The more practice we get, the better we are at the exams and in life in general. Pls join me at My DEN.

It is sorta covered in the JavaRanch Style Guide. |