## Книга: Introduction to Microprocessors and Microcontrollers

## Converting denary to binary

### Converting denary to binary

Of course, if someone were to ask us for the binary equivalent of nine we could just start from zero and count up until we reach nine. This is a boring way to do it and with larger numbers like 1 000 000_{10} it would be very tedious indeed. Here is a better way. The method will be explained using the conversion of 52_{10} to binary as an example.

**A worked example**

Convert 52_{10} to binary

Step 1: Write down the number to be converted

52

Step 2: Divide it by 2 (because 2 is the base of the binary system), write the whole number part of the answer underneath and the remainder 0 or 1 alongside

52

26 0

Step 3: Divide the answer (26) by 2 and record the remainder (0) as before

52

26 0

13 0

Step 4: Divide the 13 by 2 and write down the answer (6) and the remainder (1)

52

26 0

13 0

6 1

Step 5: 2 into 6 goes 3 remainder 0

52

26 0

13 0

6 1

3 0

Step 6: Dividing 3 gives an answer of 1 and a remainder of 1

52

26 0

13 0

6 1

3 0

1 1

Step 7: Finally, dividing the 1 by 2 will give 0 and a remainder of 1

52

26 0

13 0

6 1

3 0

1 1

0 1

Step 8: We cannot go any further with the divisions because all the answers will be zero from now on. The binary number now appears in the remainder column. To get the answer read the remainder column from the bottom UPWARDS

52

26 0 = 1101002

13 0 ?

6 1 ?

3 0 ?

1 1

0 1

**Method**

1 Divide the denary number by 2 – write the whole number result underneath and the remainder in a column to the right.

2 Repeat the process until the number is reduced to zero.

3 The binary number is found by reading the remainder column from the bottom upwards.

**Another example**

Here is one for you to try. If you get stuck, the solution is given below. Convert 218710 to a binary number

2187

1093 1 = 1000100010112

546 1 ?

273 0 ?

136 1 ?

68 0 ?

34 0

17 0

8 1

4 0

2 0

1 0

0 1

Doing it by calculator: Many scientific calculators can do the conversion of denary to binary for us. Unfortunately, they are limited to quite low numbers by the number of digits able to be seen on the screen. To do a conversion, we need:

1 A scientific calculator that can handle different number bases.

2 The instruction booklet.

3 About half an hour to spare – or a week if you have lost the instructions.

The exact method varies but on my elderly Casio it goes something like this:

To tell the calculator that the answer has to be in binary I have to press mode mode 3 then the ‘binary’ key.

It now has to be told that the input number is decimal. This is the exciting key sequence logic logic logic 1 now just put in our number 52 and press the = key and out will pop the answer 110100.

- The noise problem
- A complete cure for electrical noise
- Thermal noise
- Partition noise
- How much noise can we put up with?
- Using just two digits
- How do we count?
- The basic basis of bases
- Counting with only two figures
- Confusion and the cure
- Converting denary to binary
- Converting binary to denary
- Bits, bytes and other things
- Quiz time 2

- Hexadecimal, or ‘hex’ to its friends
- 2. Binary – the way micros count
- The only problem with binary
- Converting binary to denary
- Converting denary to hex
- Converting binary to hex
- Binary Serialization
- 13.5. Binary Utilities
- 13.6. Miscellaneous Binary Utilities
- 1.6 Converting Binary Numbers into Decimal
- 1.7 Converting Decimal Numbers into Binary
- 1.8 Converting Binary Numbers into Hexadecimal