0% found this document useful (0 votes)
9 views

Ch1_floating_point_numbers

The document discusses the conversion between different number systems, including binary, octal, and hexadecimal, and provides methods for converting floating-point numbers. It explains how floating-point numbers are stored in registers, detailing the representation of the sign, characteristic, and mantissa, as well as the use of excess-5 notation for exponents. Additionally, it covers special IEEE floating-point numbers and the process of converting floating-point representations back to decimal form.

Uploaded by

2491178958
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Ch1_floating_point_numbers

The document discusses the conversion between different number systems, including binary, octal, and hexadecimal, and provides methods for converting floating-point numbers. It explains how floating-point numbers are stored in registers, detailing the representation of the sign, characteristic, and mantissa, as well as the use of excess-5 notation for exponents. Additionally, it covers special IEEE floating-point numbers and the process of converting floating-point representations back to decimal form.

Uploaded by

2491178958
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 12

Floating-Point

Numbers
Mohammad Ali Javidian
Conversion between binary and
octal
Example: How many bits required to store the octal numbers, i.e., numbers in the
range of 0 to 7?

To convert an octal number to binary, expand each octal digit to its equivalent 3-bit
binary representation.
Example: Convert to binary.

To convert a binary number to octal, group the bits into sets of three, beginning at
the right of the binary number, and convert each resulting 3-bit binary to its
equivalent octal digit. If extra bits are needed on the left to make a set of three bits,
fill in with 0s.
Example: Convert to octal.
Conversion between binary and
hexadecimal
Example: How many bits required to store the hexadecimal numbers, i.e., numbers in
the range of 0 to 15?

To convert a hexadecimal number to binary, expand each hexadecimal digit to its
equivalent 4-bit binary representation.
Example: Convert to binary.

To convert a binary number to hexadecimal, group the bits into sets of four,
beginning at the right of the binary number, and convert each resulting 4-bit binary to
its equivalent hexadecimal digit. If extra bits are needed on the left to make a set of
three bits, fill in with 0s.
Example: Convert to hexadecimal.
Conversion between octal and
hexadecimal
To convert from octal to hexadecimal (and vice versa) directly, we
convert the given number to binary first and then we convert the
resulting binary to the requested base.

Example: Convert to octal.

Example: Convert to hexadecimal.


Floating-Point Numbers
• Real numbers are represented in a computer in floating-point notation.
We write a number in floating-point by expressing it as a number
between 0.1 and 1, times a power of 10.
Example: Express 265.0 and 0.00000107 in floating-point.

Note: The decimal part of a number in floating-point form is called the


mantissa, and the power of 10 is called the exponent. The precision of a
floating-point number is the number of significant digits in its mantissa.
How to register a Floating-Point
Number (normal form)?
• Assume that there is one and only register, F, contains five decimal digits.

0 6 3 1 5
Sign Characteristic Mantissa

• how can we store negative exponents? We do so by using a device that is employed


in most actual floating-point systems and that enables us to represent exponents in
the range -5 to + 4. To store an exponent in this range in F, add 5 to the exponent,
obtaining a value between 0 and 9. The number we obtain by adding 5 to the
exponent is called the characteristic of the number. The exponent is said to be stored
using excess-5 notation because the characteristic is 5 more than the exponent it
represents.
Example: Show how +265, +0.00107, and -3.49 are stored in normal form in F.
Decimal to 16-bit Floating-Point:
(1 sign bit + 5-bit characteristic + 10-bit mantissa)

Sign Characteristic Mantissa

1) Convert to binary,
2) Write as normalized scientific notation with 1 before the binary point (i.e.,
the mantissa will always have a leading 1),
3) Determine the sign bit: 0 for positive numbers and 1 for negative
numbers,
4) Write the characteristic in binary 5 bits, i.e., ,
5) Drop 1. from the mantissa, pad to 10 bits and store,
6) Write as hexadecimal if needed & add the indicator 0x at the beginning.
Example: Convert 23.125 to 16bfp (16-bit floating-point).
Decimal to 32-bit Floating-Point :
(1 sign bit + 8-bit characteristic + 23-bit mantissa)

Sign Characteristic Mantissa


1) Convert to binary,
2) Write as normalized scientific notation with 1 before the binary point (i.e.,
the mantissa will always have a leading 1),
3) Determine the sign bit: 0 for positive numbers and 1 for negative numbers,
4) Write the characteristic in binary 8 bits, i.e.,
,
5) Drop 1. from the mantissa, pad to 23 bits and store.
6) Write as hexadecimal if needed & add the indicator 0x at the beginning.
Example: Convert 23.125 to 32bfp (16-bit floating-point).
IEEE Special Numbers
• Zero
o Exponent all zeros
o Mantissa all zeros
• Infinity
o Exponent all ones
o Mantissa all zeros
o Positive or negative infinity depends on the sign bit
• NAN – Not A Number
o Exponent all ones
o Mantissa not zero
• Largest Magnitude Representable Number:
o Characteristic = 11110 and Mantissa = 1111111111
• Smallest Magnitude Representable Number:
o Characteristic = 00001 and Mantissa = 0000000000
Floating-Point to decimal
1) If needed, convert hex to binary pattern,
2) Determine sign, characteristic, and mantissa parts,
3) Convert the characteristic to decimal and compute the exponent as
follows:
4) Add 1. to the beginning of the stored mantissa (drop the trailing zeros),
5) Write the resulting number in normalized scientific notation,
6) Write as fractional binary (Denormalize),
7) Convert to decimal, make sure to include the sign if it is negative.
Example: Convert 0xB8C0 and 0x439C0000 to decimal.
Encoding in ASCII and
Hexadecimal
• ASCII – American Standard Code for Information Interchange.
Represent characters in computer memory. 128 or 256 characters
represented.
• We can represent words in ASCII,
• We can use hex to represent binary numbers, floating point numbers,
or ASCII characters. The meaning depends on the context.
Example: Represent the word HELP in hex:
H=72=x48, E=69=x45, L=76=4C, P=80=x50
0x48454C50 = HELP

You might also like