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

1.22 Converting a Floating Point Number into Decimal

To convert a given floating point number into decimal, we have to find the mantissa and the exponent of the number and then convert into decimal as just shown. Some examples are given here.

Example 1.30

Find the decimal equivalent of the floating point number: 0 10000001 10000000000000000000000

Solution 1.30

Here

sign = positive
exponent = 129 – 127 = 2
mantissa = 2-1 = 0.5

The decimal equivalent of this number is +1.5 ? 22 = +6.0.

Example 1.31

Find the decimal equivalent of the floating point number: 0 10000010 11000000000000000000

Solution 1.31

In this example,

sign = positive
exponent = 130 – 127 = 3
mantissa = 2-1 + 2-2 = 0.75

The decimal equivalent of the number is +1.75 ? 23 = 14.0.

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


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