O'Reilly logo

Programmer's Guide to Java™ Certification, A: A Comprehensive Primer, Second Edition by Rolf W. Rasmussen, Khalid A. Mughal

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

G.3. Converting Decimals

Converting Decimals to Binary Numbers

In order to convert decimals to binaries, we reverse the process outlined in Section G.1 for converting a binary to a decimal.

4110 =20×2+ 1Dividing 41 by 2, gives the quotient 20 and remainder 1.
2010 =10×2+ 0We again divide the current quotient 20 by 2.
1010 =5×2+ 0 
510 =2×2+ 1We repeat this procedure until ...
210 =1×2+ 0 
110 =0×2+ 1... the quotient is 0.
4110 =1010012

The divisor used in the steps above is the base of the target number system (binary, base 2). The binary value, 1010012, is represented by the remainders, with the last remainder as the left-most bit. Back substitution of the quotient gives the same result:

4110= (((((0×2 + 1)×2 + 0)×2 + 1)×2 + 0)×2 + 0)×2 + 1
 = 1×2 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required