ReviewEssays.com - Term Papers, Book Reports, Research Papers and College Essays
Search

Float to Decimal Conversion

Essay by   •  October 16, 2017  •  Thesis  •  718 Words (3 Pages)  •  1,855 Views

Essay Preview: Float to Decimal Conversion

Report this essay
Page 1 of 3

[pic 1]
[pic 2]

Float to Decimal Conversion

[pic 3] Floating-Point Conversion Examples   [pic 4][pic 5] Binary/Boolean Main Index

[pic 6]

[Decimal to Floating-Point Conversions] [Float to Decimal Conversion]

The Conversion Procedure

The rules for converting a floating point number into decimal are simply to reverse of the decimal to floating point conversion:

  1. If the original number is in hex, convert it to binary.
  2. Separate into the sign, exponent, and mantissa fields.
  3. Extract the mantissa from the mantissa field, and restore the leading one. You may also omit the trailing zeros.
  4. Extract the exponent from the exponent field, and subtract the bias to recover the actual exponent of two. As before, the bias is 2k−1 − 1, where k is the number of bits in the exponent field, giving 3 for the 8-bit format and 127 for the 32-bit.
  5. De-normalize the number: move the binary point so the exponent is 0, and the value of the number remains unchanged.
  6. Convert the binary value to decimal. This is done just as with binary integers, but the place values right of the binary point are fractions.
  7. Set the sign of the decimal number according to the sign bit of the original floating point number: make it negative for 1; leave positive for 0.

If the binary exponent is very large or small, you can convert the mantissa directly to decimal without de-normalizing. Then use a calculator to raise two to the exponent, and perform the multiplication. This will give an approximate answer, but is sufficient in most cases.

Examples Using The Conversion Procedure

  • Convert the 8-bit floating point number e7 (in hex) to decimal.
  1. Convert: e716 = 111001112.
  2. Seprate: 11100111
  3. Mantissa: 1.0111
  4. Exponent: 1102 = 610; 6 − 3 = 3.
  5. De-normalize: 1.01112 × 23 = 1011.1
  6. Convert:

Exponents

23

22

21

20

2-1

Place Values

8

4

2

1

0.5

Bits

1

0

1

1

.

1

Value

8

 

 

+

2

+

1

+

0.5

=

11.5

  1. Sign: negative.

Result: e7 is -11.5

  • Convert the 8-bit floating point number 26 (in hex) to decimal.
  1. Convert and separate: 2616 = 00100110 2
  2. Exponent: 0102 = 210; 2 − 3 = -1.
  3. Denormalize: 1.0112 × 2-1 = 0.1011.
  4. Convert:

Exponents

20

2-1

2-2

2-3

2-4

Place Values

1

0.5

0.25

0.125

0.0625

Bits

0

.

1

0

1

1

Value

0.5

+

0.125

+

0.0625

=

0.6875

  1. Sign: positive

Result: 26 is 0.6875.

  • Convert the 8-bit floating point number d3 (in hex) to decimal.
  1. Convert and separate: d316 = 11010011 2
  2. Exponent: 1012 = 510; 5 − 3 = 2.
  3. Denormalize: 1.00112 × 22 = 100.11.
  4. Convert:

Exponents

22

21

20

2-1

2-2

Place Values

4

2

1

0.5

0.25

Bits

1

0

0

.

1

1

Value

4

 

 

 

 

+

0.5

+

0.25

=

4.75

  1. Sign: negative

Result: d3 is -4.75.

  • Convert the 32-bit floating point number 44361000 (in hex) to decimal.
  1. Convert and separate: 4436100016 = 01000100001101100001000000000000 2
  2. Exponent: 100010002 = 13610; 136 − 127 = 9.
  3. Denormalize: 1.011011000012 × 29 = 1011011000.01.
  4. Convert:

Exponents

29

28

27

26

25

24

23

22

21

20

2-1

2-2

Place Values

512

256

128

64

32

16

8

4

2

1

0.5

0.25

Bits

1

0

1

1

0

1

1

0

0

0

.

0

1

Value

512

 

 

+

128

+

64

 

 

+

16

+

8

 

 

 

 

 

 

+

0.25

=

728.25

  1. Sign: positive

Result: 44361000 is 728.25.

  • Convert the 32-bit floating point number be580000 (in hex) to decimal.
  1. Convert and separate: be58000016 = 10111110010110000000000000000000 2
  2. Exponent: 011111002 = 12410; 124 − 127 = -3.
  3. Denormalize: 1.10112 × 2-3 = 0.0011011.
  4. Convert:

Exponents

20

2-1

2-2

2-3

2-4

2-5

2-6

2-7

Place Values

1

0.5

0.25

0.125

0.0625

0.03125

0.015625

0.0078125

Bits

0

.

0

0

1

1

0

1

1

Value

0.125

+

0.0625

+

0.015625

+

0.0078125

=

0.2109375

  1. Sign: negative

Result: be580000 is -0.2109375.

  • Convert the 32-bit floating point number a3358000 (in hex) to decimal.
  1. Convert and separate: a335800016 = 10100011001101011000000000000000 2
  2. Exponent: 010001102 = 7010; 70 − 127 = -57.
  3. Since the exponent is far from zero, convert the original (normalized) mantissa:

Exponents

20

2-1

2-2

2-3

2-4

2-5

2-6

2-7

2-8

Place Values

1

0.5

0.25

0.125

0.0625

0.03125

0.015625

0.0078125

0.00390625

Bits

1

.

0

1

1

0

1

0

1

1

Value

1

+

0.25

+

0.125

+

0.03125

+

0.0078125

+

0.00390625

=

1.41796875

  1. Use calculator to find 1.41796875 × 2-57. You should get something like 9.83913471531 × 10-18 .
  2. Sign: negative

Result: a3358000 is about -9.83913471531 × 10-18 .

  • Convert the 32-bit floating point number 76650000 (in hex) to decimal.
  1. Convert and separate: 7665000016 = 01110110011001010000000000000000 2
  2. Exponent: 111011002 = 23610; 236 − 127 = 109.
  3. Since the exponent is far from zero, convert the original (normalized) mantissa:

Exponents

20

2-1

2-2

2-3

2-4

2-5

2-6

2-7

Place Values

1

0.5

0.25

0.125

0.0625

0.03125

0.015625

0.0078125

Bits

1

.

1

1

0

0

1

0

1

Value

1

+

0.5

+

0.25

+

0.03125

+

0.0078125

=

1.7890625

  1. Use calculator to find 1.7890625 × 2109. You should get something like 1.16116794981 × 1033 .
  2. Sign: positive

Result: 76650000 is about 1.16116794981 × 1033 .

...

...

Download as:   txt (6.4 Kb)   pdf (138.1 Kb)   docx (26.9 Kb)  
Continue for 2 more pages »
Only available on ReviewEssays.com