Книга: Advanced PIC Microcontroller Projects in C

1.11 Converting Decimal Numbers into Hexadecimal

1.11 Converting Decimal Numbers into Hexadecimal

To convert a decimal number into hexadecimal, divide the number repeatedly by 16 and take the remainders. The first remainder is the LSD, and the last remainder is the MSD.

Example 1.13

Convert decimal number 23810 into hexadecimal.

Solution 1.13

Dividing the number repeatedly by 16:

238/16 ? 14 Remainder 14 (E) (LSD)
14/16  ? 0  Remainder 14 (E) (MSD)

The hexadecimal number is EE16.

Example 1.14

Convert decimal number 68410 into hexadecimal.

Solution 1.14

Dividing the number repeatedly by 16:

684/16 ? 42 Remainder 12 (C) (LSD)
42/16  ? 2  Remainder 10 (A)
2/16   ? 0  Remainder 2      (MSD)

The hexadecimal number is 2AC16.

Оглавление книги


Генерация: 0.654. Запросов К БД/Cache: 2 / 0
поделиться
Вверх Вниз