Class Notes (1,100,000)
CA (620,000)
McGill (30,000)
COMP (700)
Lecture 2

COMP 273 Lecture Notes - Lecture 2: Normalized Number, Single-Precision Floating-Point Format, Decimal Mark

Computer Science (Sci)
Course Code
COMP 273
Piotr Przytycki

This preview shows pages 1-2. to view the full 6 pages of the document.
COMP 273 2 - IEEE floating point Jan. 13, 2016
Fixed Point
We are mostly discussing floating point numbers today, but I want to mention briefly that some
computers represent non-integers numbers using fixed point. Fixed point means we have a constant
number of bits (or digits) to the left and right of the binary (or decimal) point.
For example, we might have eight digits to the left of the decimal point and two digits to the
right. An example is 23953223.49. You are familiar with representations have two digits to the
right. That is how our currency works (but the number to the left is not fixed with currency). An
example in binary is 10.1101 where we have two and four bits to the left and right, respectively.
Note that I used the term ”digits” for base 10, and ”bits” for base 2.
We can represent negative numbers in fixed point using two’s complement. Take the number
6.5 in decimal which is 110.1 in binary. Suppose (arbitrarily) that we represent it with four bits to
the left and four to the right of the binary point. To represent -6.5 in binary, we invert the bits and
add what we need to get back to 0.
1001.0111 invert bits
+ 0000.0001 add .0001
We get the representation of -6.5 by adding the 2nd and 3rd rows of the sum:
1001.0111 invert bits
+ 0000.0001 add .0001
1001.1000 -6.5 as signed fixed point
Scientific Notation
Let’s return to floating point and consider a number representation called “scientific notation,”
which most of you learned about in high school. You know that you can represent very large
decimal numbers or very small decimal numbers by writing, for example:
300,000,000 = 3 ×108=3.0E +8
which is the speed of light in meters per second, and
.00000456 = 4.56 ×106=4.56E 6
which has no particular significance to my knowledge.
In normalized scientific notation in base 10, there is exactly one digit to the left of the decimal
point and this digit is from 1 to 9 (not 0). Note that the number 0 cannot be written in normalized
scientific notation. Examples of normalized binary numbers are shown blow on the right side of the
(1000.01)2= 1.00001 ×23
(0.111)2= 1.11 ×21
last updated: 14th Jan, 2016 1

Only pages 1-2 are available for preview. Some parts have been intentionally blurred.

COMP 273 2 - IEEE floating point Jan. 13, 2016
A normalized binary number has the form:
where the is called the significand (or mantissa) and Eis the exponent. Note that it
is impossible to encode the number 0 in normalized form.
The number of bits in the significand is called the number of significant bits. Note that we don’t
count the first bit when counting the number of significant bit. (In decimal, we do have to specify
the most significant digit since it can be anything from 1 to 9, so it is included in the count.)
IEEE floating point standard
To represent floating point numbers in a computer, we need to make some choices:
how many bits to use for the significand?
how many bit to use for the exponent?
how to represent the exponent?
how to represent the sign of the number?
how to represent the number 0 ?
Until the late 1970’s, different computer manufacturers made different choices. This meant that the
same software produced different results when run on different computers. Obviously this was not
desirable. A standard was introduced in 1985 by the IEEE organization.1The standard (number
”754”, i.e. there are lots of different standards) consists of two representations for floating point
numbers. One is called single precision and uses 32 bits. The other is called double precision and
uses 64 bits. This representation is used in nearly all computers you will find today.
Single precision
Single precision represents a floating point number using 32 bits (4 bytes, that is, one byte is 8
bits). We number the bits from right to left. Bit 31 is the leftmost and bit 0 is the rightmost.
bits 0-22 (23 bits) are used for the significand
bits 23-30 (8 bits) are used for the exponent
bit 31 (1 bit) is used for the sign (0 positive, 1 negative).
Because the standard uses normalized numbers, the 1 bit to the left of the binary point in
1.does not need to be coded since it is always there. The significand only refers to
what is to the right of the binary point.
The coding of the exponent is subtle. You might expect the exponent should be encoded
with two’s complement, since you want to allow positive exponents (large numbers) and negative
exponents (small numbers). This is not the way the IEEE chose to do it, however.
1Institute of Electrical and Electronics Engineers, Inc. See
last updated: 14th Jan, 2016 2
You're Reading a Preview

Unlock to view full version