+ All Categories
Home > Documents > Number Systems & Operations Part I. Decimal Numbers (Base 10) People use decimal numbers. I hope you...

Number Systems & Operations Part I. Decimal Numbers (Base 10) People use decimal numbers. I hope you...

Date post: 17-Jan-2016
Category:
Upload: geoffrey-carroll
View: 234 times
Download: 0 times
Share this document with a friend
48
Number Systems & Number Systems & Operations Operations Part I Part I
Transcript
Page 1: Number Systems & Operations Part I. Decimal Numbers (Base 10) People use decimal numbers. I hope you know this very well. However, let’s review: Ten digits.

Number Systems & Number Systems & OperationsOperations

Part IPart I

Page 2: Number Systems & Operations Part I. Decimal Numbers (Base 10) People use decimal numbers. I hope you know this very well. However, let’s review: Ten digits.

Decimal Numbers (Base 10)Decimal Numbers (Base 10)

People use decimal numbers.People use decimal numbers.

I hope you know this very well. However, I hope you know this very well. However, let’s review:let’s review: Ten digits Ten digits 0-9 0-9 The value of a digit is determined by its The value of a digit is determined by its

positionposition in the number. in the number.

. . . 10. . . 1022101011101000..1010-1-11010-2-21010--

33 . . . . . .

Page 3: Number Systems & Operations Part I. Decimal Numbers (Base 10) People use decimal numbers. I hope you know this very well. However, let’s review: Ten digits.

Binary NumbersBinary Numbers

There are only 2 There are only 2 digits (0 and 1) and digits (0 and 1) and we can do binary we can do binary counting as shown in counting as shown in the table.the table.

DecimalDecimal BinaryBinary

00 00

11 11

22 1010

33 1111

44 100100

55 101101

66 110110

77 111111

88 10001000

99 10011001

1010 10101010

Page 4: Number Systems & Operations Part I. Decimal Numbers (Base 10) People use decimal numbers. I hope you know this very well. However, let’s review: Ten digits.

Binary Numbers (Base 2)Binary Numbers (Base 2)

The weighting structure of binary numbersThe weighting structure of binary numbers

22n-1n-1 . . . 2 . . . 23 3 222 2 221 1 2200..22-1 -1 22-2-2 . . . 2 . . . 2-n-n

Positive power of two Positive power of two

(whole number)(whole number)

Negative power of twoNegative power of two

(fractional number)(fractional number)

2255 2244 2233 2222 2211 2200 22-1-1 22-2-2 22-3-3 22-4-4 22-5-5 22-6-6

3232 1616 88 44 22 11 1/21/2 1/41/4 1/81/8 1/161/16 1/321/32 1/641/64

0.50.5 0.250.25 0.1250.125 0.06250.0625 0.031250.03125 0.0156250.015625

Page 5: Number Systems & Operations Part I. Decimal Numbers (Base 10) People use decimal numbers. I hope you know this very well. However, let’s review: Ten digits.

Binary-to-Decimal ConversionBinary-to-Decimal Conversion

Add the weights of all 1s in a binary number to get the Add the weights of all 1s in a binary number to get the decimal value.decimal value.

ex: convert 1101101ex: convert 110110122 to decimal to decimal

1101101110110122 = 2= 26 6 + 2+ 25 5 + 2+ 23 3 + 2+ 22 2 + 2+ 200

= 64 + 32 + 8 + 4 + 1= 64 + 32 + 8 + 4 + 1= 109= 109

WeightWeight 2266 2255 2244 2233 2222 2211 2200

binbin 11 11 00 11 11 00 11

Page 6: Number Systems & Operations Part I. Decimal Numbers (Base 10) People use decimal numbers. I hope you know this very well. However, let’s review: Ten digits.

Binary-to-Decimal ConversionBinary-to-Decimal Conversion

Fractional binary exampleFractional binary example

ex: convert 0.1011 to decimalex: convert 0.1011 to decimal

0.1011 0.1011 = 2= 2-1 -1 + 2+ 2-3 -3 + 2+ 2-4-4

= 0.5 + 0.125 + 0.0625= 0.5 + 0.125 + 0.0625

= 0.6875 = 0.6875

WeightWeight 22-1-1 22-2-2 22-3-3 2244

binbin 11 00 11 11

Page 7: Number Systems & Operations Part I. Decimal Numbers (Base 10) People use decimal numbers. I hope you know this very well. However, let’s review: Ten digits.

Decimal-to-Binary ConversionDecimal-to-Binary Conversion

Sum-of-weights methodSum-of-weights method To get the binary number for a given decimal To get the binary number for a given decimal

number, find the binary weights that add up to number, find the binary weights that add up to the decimal number.the decimal number.

ex: convert 12ex: convert 1210 10 , 25, 2510 10 , 58, 5810 10 , 82, 821010 to binary to binary

12 = 8+4 = 212 = 8+4 = 233+2+22 2 = 1100= 110025 = 16+8+1 = 225 = 16+8+1 = 244+2+233+2+200 = 11001 = 1100158 = 32+16+8+2 = 258 = 32+16+8+2 = 255+2+244+2+233+2+211 = 111010 = 11101082 = 64+16+2 = 282 = 64+16+2 = 266+2+244+2+211 = 1010010 = 1010010

Page 8: Number Systems & Operations Part I. Decimal Numbers (Base 10) People use decimal numbers. I hope you know this very well. However, let’s review: Ten digits.

Stop when the whole-number quotient is 0

Decimal-to-Binary ConversionDecimal-to-Binary Conversion

Repeated division-by-Repeated division-by-2 method2 method To get the binary To get the binary

number for a given number for a given decimal number, decimal number, divide the decimal divide the decimal number by 2 until the number by 2 until the quotient is 0. quotient is 0. Remainders Remainders formform the the binary number.binary number.

remainderremainder

12/212/2 == 66 00

6/26/2 == 33 00

3/23/2 == 11 11

1/21/2 == 00 11

LSB

MSB

12121010 = 1100 = 110022

Page 9: Number Systems & Operations Part I. Decimal Numbers (Base 10) People use decimal numbers. I hope you know this very well. However, let’s review: Ten digits.

Decimal-to-Binary ConversionDecimal-to-Binary Conversion

Converting decimal fractions to binaryConverting decimal fractions to binary Sum-of-weightsSum-of-weights

This method can be applied to fractional decimal This method can be applied to fractional decimal numbers, as shown in the following example:numbers, as shown in the following example:

0.625 = 0.5+0.125 = 20.625 = 0.5+0.125 = 2-1-1+2+2-3-3 = 0.101 = 0.101 Repeated multiplication by 2Repeated multiplication by 2

Decimal fraction can be converted to binary by Decimal fraction can be converted to binary by repeated multiplication by 2repeated multiplication by 2 (see details in the (see details in the following slide.)following slide.)

Page 10: Number Systems & Operations Part I. Decimal Numbers (Base 10) People use decimal numbers. I hope you know this very well. However, let’s review: Ten digits.

Repeated Multiplication by 2 Repeated Multiplication by 2 (by example)(by example)

ex: convert the decimal fraction 0.3125 to binaryex: convert the decimal fraction 0.3125 to binary

carrycarry

0.3125 x 20.3125 x 2 == 0.0.625625 00

0.0.625625 x 2 x 2 == 1.1.2525 11

0.0.2525 x 2 x 2 == 0.0.5050 00

0.0.5050 x 2 x 2 == 1.1.0000 11

Continue to the desired number of decimal places or stop when the fractional part is all zero

MSB

LSB

0.31250.31251010 = 0.0101 = 0.010122

Page 11: Number Systems & Operations Part I. Decimal Numbers (Base 10) People use decimal numbers. I hope you know this very well. However, let’s review: Ten digits.

Binary ArithmeticBinary Arithmetic

Basic of binary arithmeticBasic of binary arithmetic Binary additionBinary addition Binary subtractionBinary subtraction Binary multiplicationBinary multiplication Binary divisionBinary division

Page 12: Number Systems & Operations Part I. Decimal Numbers (Base 10) People use decimal numbers. I hope you know this very well. However, let’s review: Ten digits.

Binary AdditionBinary Addition

The four basic rules for adding digits are The four basic rules for adding digits are as follows:as follows: 0+0=0+0=00 sum of 0 with a carry of 0 sum of 0 with a carry of 0 0+1=0+1=11 sum of 1 with a carry of 0 sum of 1 with a carry of 0 1+0=1+0=11 sum of 1 with a carry of 0 sum of 1 with a carry of 0 1+1=1+1=1100 sum of 0 with a carry of 1 sum of 0 with a carry of 1

Page 13: Number Systems & Operations Part I. Decimal Numbers (Base 10) People use decimal numbers. I hope you know this very well. However, let’s review: Ten digits.

Binary Addition (by example)Binary Addition (by example)

11 3+11 +3110 6

100 4+ 10 +2 110 6

111 7+ 11 +31010 10

110 6+100 +41010 10

Page 14: Number Systems & Operations Part I. Decimal Numbers (Base 10) People use decimal numbers. I hope you know this very well. However, let’s review: Ten digits.

Binary SubtractionBinary Subtraction

The four basic rules for subtracting digits The four basic rules for subtracting digits are as follows:are as follows: 0-0 = 0-0 = 00 1-1 = 1-1 = 00 1-0 = 1-0 = 11 10-1 = 10-1 = 11 ; 0-1 with a borrow of 1; 0-1 with a borrow of 1

Page 15: Number Systems & Operations Part I. Decimal Numbers (Base 10) People use decimal numbers. I hope you know this very well. However, let’s review: Ten digits.

Binary Subtraction (by example)Binary Subtraction (by example)

11 3-01 -1 10 2

11 3-10 -2 01 1

101 5-011 -3 010 2

Page 16: Number Systems & Operations Part I. Decimal Numbers (Base 10) People use decimal numbers. I hope you know this very well. However, let’s review: Ten digits.

Binary MultiplicationBinary Multiplication

The four basic rules for multiplying digits are as The four basic rules for multiplying digits are as follows:follows: 0x0 = 0x0 = 00 0x1 = 0x1 = 00 1x0 = 1x0 = 00 1x1 = 1x1 = 11

Multiplication is performed with binary numbers Multiplication is performed with binary numbers in the same manner as with decimal numbers.in the same manner as with decimal numbers. It involves forming partial products, shifting each It involves forming partial products, shifting each

successive partial product left one place, and then successive partial product left one place, and then adding all the partial products.adding all the partial products.

Page 17: Number Systems & Operations Part I. Decimal Numbers (Base 10) People use decimal numbers. I hope you know this very well. However, let’s review: Ten digits.

Binary Multiplication (by example)Binary Multiplication (by example)

11 x11 11+111001

3x3 9

101 x111 101 101 +101100011

5x7

35

Page 18: Number Systems & Operations Part I. Decimal Numbers (Base 10) People use decimal numbers. I hope you know this very well. However, let’s review: Ten digits.

Binary DivisionBinary Division

Division in binary follows the same Division in binary follows the same procedure as division in decimal.procedure as division in decimal.

23 6 60

10 11 110 11 000

11 10 110 10 10 10 00

32 6 60

Page 19: Number Systems & Operations Part I. Decimal Numbers (Base 10) People use decimal numbers. I hope you know this very well. However, let’s review: Ten digits.

1’s and 2’s Complements1’s and 2’s Complements

They are important since they permit the They are important since they permit the presentation of presentation of negative numbersnegative numbers..

The method of 2’s complement arithmetic The method of 2’s complement arithmetic is commonly used in computers to is commonly used in computers to handle handle negative numbersnegative numbers..

Page 20: Number Systems & Operations Part I. Decimal Numbers (Base 10) People use decimal numbers. I hope you know this very well. However, let’s review: Ten digits.

Finding the 1’s complementFinding the 1’s complement

Very simple: change each bit in a number to get Very simple: change each bit in a number to get the 1’s complement the 1’s complement

ex: find 1’s complement of 11100101ex: find 1’s complement of 1110010122

BinaryBinary 11 11 11 00 00 11 00 11

1’s complement1’s complement 00 00 00 11 11 00 11 00

Page 21: Number Systems & Operations Part I. Decimal Numbers (Base 10) People use decimal numbers. I hope you know this very well. However, let’s review: Ten digits.

Finding the 2’s ComplementFinding the 2’s Complement

Add 1 to the 1’s complement to get the 2’s Add 1 to the 1’s complement to get the 2’s complement.complement.ex: ex: 10110010 10110010 01001101 01001101 01001110 01001110

An alternative method:An alternative method: Start at the right with the LSB and write the Start at the right with the LSB and write the

bits as they are up to and including the first 1.bits as they are up to and including the first 1. Take the 1’s complement of the remaining Take the 1’s complement of the remaining

bits.bits.

1011001010110010 1011100010111000 binarybinary

0100111001001110 0100100001001000 2’s 2’s compcomp

1’s complement1’s complement 2’s complement2’s complement+1+1

Page 22: Number Systems & Operations Part I. Decimal Numbers (Base 10) People use decimal numbers. I hope you know this very well. However, let’s review: Ten digits.

Signed NumbersSigned Numbers

Digital systems, such as computer, must Digital systems, such as computer, must be able to handle both positive and be able to handle both positive and negative numbers.negative numbers.

A A signed binarysigned binary number consists of both number consists of both signsign and and magnitudemagnitude information. information. The The signsign indicates whether a number is indicates whether a number is

positive or negative.positive or negative. The The magnitudemagnitude is the value of the number. is the value of the number.

Page 23: Number Systems & Operations Part I. Decimal Numbers (Base 10) People use decimal numbers. I hope you know this very well. However, let’s review: Ten digits.

Signed NumbersSigned Numbers

There are 3 forms in which signed There are 3 forms in which signed integerinteger numbers can be represented in binary:numbers can be represented in binary: Sign-magnitude (least used)Sign-magnitude (least used) 1’s complement1’s complement 2’s complement (most important)2’s complement (most important)

Non-integer and very large or small Non-integer and very large or small numbers can be expressed in floating-numbers can be expressed in floating-point format.point format.

Page 24: Number Systems & Operations Part I. Decimal Numbers (Base 10) People use decimal numbers. I hope you know this very well. However, let’s review: Ten digits.

The Sign BitThe Sign Bit

The left-most bit in a The left-most bit in a signed binary numbersigned binary number is the is the sign bitsign bit.. It tells you whether the number is It tells you whether the number is positivepositive (sign (sign

bit = 0)bit = 0) or or negative negative (sign bit = 1)(sign bit = 1)..

Page 25: Number Systems & Operations Part I. Decimal Numbers (Base 10) People use decimal numbers. I hope you know this very well. However, let’s review: Ten digits.

Sign-Magnitude FormSign-Magnitude Form

The left-most bit is the The left-most bit is the sign bitsign bit and the and the remaining bits are the remaining bits are the magnitude bitsmagnitude bits.. The magnitude bits are in The magnitude bits are in truetrue binary for both binary for both

positive and negative numbers.positive and negative numbers.

ex: the decimal number +25 is expressed as an 8-bit ex: the decimal number +25 is expressed as an 8-bit signed binary number as: signed binary number as:

0000110010011001While the decimal number -25 is expressed asWhile the decimal number -25 is expressed as

1100110010011001

Page 26: Number Systems & Operations Part I. Decimal Numbers (Base 10) People use decimal numbers. I hope you know this very well. However, let’s review: Ten digits.

Sign-Magnitude FormSign-Magnitude Form

“ “ In the sign-magnitude form, a In the sign-magnitude form, a negative numbernegative number has the same has the same

magnitude bits as the magnitude bits as the corresponding positive number corresponding positive number but the sign bit is a 1 rather but the sign bit is a 1 rather

than a 0. “ than a 0. “

Page 27: Number Systems & Operations Part I. Decimal Numbers (Base 10) People use decimal numbers. I hope you know this very well. However, let’s review: Ten digits.

1’s Complement Form1’s Complement Form

Positive numbers in 1’s complement form Positive numbers in 1’s complement form are represented the same way as the are represented the same way as the positive sign-magnitude.positive sign-magnitude.Negative numbers are the 1’s Negative numbers are the 1’s complements of the corresponding complements of the corresponding positive numbers.positive numbers.ex: the decimal number +25 is expressed as:ex: the decimal number +25 is expressed as:

0000110010011001While the decimal number -25 is expressed asWhile the decimal number -25 is expressed as

1111001101100110

Page 28: Number Systems & Operations Part I. Decimal Numbers (Base 10) People use decimal numbers. I hope you know this very well. However, let’s review: Ten digits.

1’s Complement Form1’s Complement Form

“ “ In the 1’s complement form, a In the 1’s complement form, a negative numbernegative number is the 1’s is the 1’s

complement of the corresponding complement of the corresponding positive number. “ positive number. “

Page 29: Number Systems & Operations Part I. Decimal Numbers (Base 10) People use decimal numbers. I hope you know this very well. However, let’s review: Ten digits.

2’s Complement Form2’s Complement Form

Positive numbers in 2’s complement form are Positive numbers in 2’s complement form are represented the same way as the positive represented the same way as the positive sign-magnitude and 1’s complement form.sign-magnitude and 1’s complement form.

Negative numbers are the 2’s complements Negative numbers are the 2’s complements of the corresponding positive numbers.of the corresponding positive numbers.ex: the decimal number +25 is expressed as:ex: the decimal number +25 is expressed as:

0000110010011001While the decimal number -25 is expressed asWhile the decimal number -25 is expressed as

1111001111100111

Page 30: Number Systems & Operations Part I. Decimal Numbers (Base 10) People use decimal numbers. I hope you know this very well. However, let’s review: Ten digits.

2’s Complement Form2’s Complement Form

“ “ In the 2’s complement form, a In the 2’s complement form, a negative numbernegative number is the 2’s is the 2’s

complement of the corresponding complement of the corresponding positive number. “ positive number. “

Page 31: Number Systems & Operations Part I. Decimal Numbers (Base 10) People use decimal numbers. I hope you know this very well. However, let’s review: Ten digits.

Decimal Value of Signed NumbersDecimal Value of Signed Numbers

Sign-magnitude:Sign-magnitude: Both positive and negative numbers are Both positive and negative numbers are

determined by determined by summing the weights in all the summing the weights in all the magnitudemagnitude bit positions where these are 1s bit positions where these are 1s and ignoring those positions where there are and ignoring those positions where there are 0s.0s.

The sign is determined by examination of the The sign is determined by examination of the sign bit.sign bit.

Page 32: Number Systems & Operations Part I. Decimal Numbers (Base 10) People use decimal numbers. I hope you know this very well. However, let’s review: Ten digits.

Decimal Value of Signed NumbersDecimal Value of Signed Numbers

Sign-magnitude (by example)Sign-magnitude (by example)ex: decimal values of these numbers (expressed in sign-magnitude)ex: decimal values of these numbers (expressed in sign-magnitude)

1) 100101011) 10010101 2) 01110111 2) 01110111

1) 100101011) 10010101 2) 01110111 2) 01110111

magnitudemagnitude magnitudemagnitude 2266 2 255 2 244 2 233 2 222 2 21 1 220 0 2266 2 255 2 244 2 233 2 222 2 21 1 2200

00 0 0 1 1 0 0 1 1 0 0 1 11 1 1 1 1 1 0 0 1 1 1 1 11

= 16+4+1 = 21 = 64+32+16+4+2+1 = 119= 16+4+1 = 21 = 64+32+16+4+2+1 = 119signsign signsign = 1 = 1 negative = 0 negative = 0 positive positive

Hence:Hence: 10010101 = -21 10010101 = -21 Hence:Hence: 01110111 = 119 01110111 = 119

Page 33: Number Systems & Operations Part I. Decimal Numbers (Base 10) People use decimal numbers. I hope you know this very well. However, let’s review: Ten digits.

Decimal Value of Signed NumbersDecimal Value of Signed Numbers

1’s complement:1’s complement: PositivePositive – determined by summing the – determined by summing the

weights in all bit positions where there are 1s weights in all bit positions where there are 1s and ignoring those positions where there are and ignoring those positions where there are 0s.0s.

NegativeNegative – determined by assigning a – determined by assigning a negative value to the weight of the sign bit, negative value to the weight of the sign bit, summing all the weights where there are 1’s, summing all the weights where there are 1’s, and and adding 1 to the resultadding 1 to the result..

Page 34: Number Systems & Operations Part I. Decimal Numbers (Base 10) People use decimal numbers. I hope you know this very well. However, let’s review: Ten digits.

Decimal Value of Signed NumbersDecimal Value of Signed Numbers

1’s complement (by example)1’s complement (by example)

ex: decimal values of these numbers (expressed in 1’s complement)ex: decimal values of these numbers (expressed in 1’s complement)

1) 000101111) 00010111 2) 11101000 2) 11101000

1) 00010111 1) 00010111 2) 11101000 2) 11101000

-2-277 2 266 2 255 2 244 2 233 2 222 2 21 1 220 0 -2-277 2 266 2 255 2 244 2 233 2 222 2 21 1 2200

00 0 0 0 0 1 1 0 0 1 1 11 11 11 1 1 1 1 0 0 1 1 0 0 0 0 00

= 16+4+2+1 = +23 = (-128)+64+32+8 = -24= 16+4+2+1 = +23 = (-128)+64+32+8 = -24

Hence:Hence: 00010111 = +23 00010111 = +23 Hence:Hence: 11101000 = -23 11101000 = -23

+1

Page 35: Number Systems & Operations Part I. Decimal Numbers (Base 10) People use decimal numbers. I hope you know this very well. However, let’s review: Ten digits.

Decimal Value of Signed NumbersDecimal Value of Signed Numbers

2’s complement:2’s complement: PositivePositive – determined by summing the – determined by summing the

weights in all bit positions where there are 1s weights in all bit positions where there are 1s and ignoring those positions where there are and ignoring those positions where there are 0s.0s.

NegativeNegative – the weight of the sign bit in a – the weight of the sign bit in a negative number is given a negative value.negative number is given a negative value.

Page 36: Number Systems & Operations Part I. Decimal Numbers (Base 10) People use decimal numbers. I hope you know this very well. However, let’s review: Ten digits.

Decimal Value of Signed NumbersDecimal Value of Signed Numbers

2’s complement (by example)2’s complement (by example)

ex: decimal values of these numbers (expressed in 2’s complement)ex: decimal values of these numbers (expressed in 2’s complement)

1) 010101101) 01010110 2) 10101010 2) 10101010

1) 010101101) 01010110 2) 10101010 2) 10101010

-2-277 2 266 2 255 2 244 2 233 2 222 2 21 1 220 0 -2-277 2 266 2 255 2 244 2 233 2 222 2 21 1 2200

00 1 1 0 0 1 1 0 0 1 1 11 00 11 0 0 1 1 0 0 1 1 0 0 1 1 00

= 64+16+4+2 = +86 = (-128)+32+8+2 = -86= 64+16+4+2 = +86 = (-128)+32+8+2 = -86

Hence:Hence: 01010110 = +86 01010110 = +86 Hence:Hence: 10101010 = -86 10101010 = -86

Page 37: Number Systems & Operations Part I. Decimal Numbers (Base 10) People use decimal numbers. I hope you know this very well. However, let’s review: Ten digits.

Range of Signed Integer NumbersRange of Signed Integer Numbers

The range of magnitude of a binary The range of magnitude of a binary number depends on the number of bits (n).number depends on the number of bits (n).

Total combinations = 2Total combinations = 2nn

8 bits = 256 different numbers8 bits = 256 different numbers 16 bits = 65,536 different numbers16 bits = 65,536 different numbers 32 bits = 4,294,967,296 different numbers32 bits = 4,294,967,296 different numbers

Page 38: Number Systems & Operations Part I. Decimal Numbers (Base 10) People use decimal numbers. I hope you know this very well. However, let’s review: Ten digits.

Range of Signed Integer NumbersRange of Signed Integer Numbers

For 2’s complement signed numbers:For 2’s complement signed numbers: Range = Range = -(2-(2n-1n-1)) to to +(2+(2n-1n-1-1)-1) where there is one sign bit and where there is one sign bit and n-1n-1 magnitude magnitude

ex: ex:

Negative Negative BoundaryBoundary

Positive Positive BoundaryBoundary

4 bits4 bits -(2-(233) = -8) = -8 (2(233-1) = +7-1) = +7

8 bits8 bits -(2-(277) = -128) = -128 (2(277-1) = +127-1) = +127

16 bits16 bits -(2-(21515) = -32,768) = -32,768 (2(21515-1) = +32767-1) = +32767

Page 39: Number Systems & Operations Part I. Decimal Numbers (Base 10) People use decimal numbers. I hope you know this very well. However, let’s review: Ten digits.

Floating-point numbersFloating-point numbers

How many bits do we need to represent very How many bits do we need to represent very large number?large number?Floating-point number consists of two parts plus Floating-point number consists of two parts plus a sign.a sign. Mantissa – represents the Mantissa – represents the magnitudemagnitude of the number. of the number. Exponent – represents the number of places that the Exponent – represents the number of places that the

decimal point (or binary point) is to be moved.decimal point (or binary point) is to be moved. Decimal number example: 241,506,800Decimal number example: 241,506,800

Mantissa = 0.2415068Mantissa = 0.2415068Exponent = 10Exponent = 1099

Can be written as FP as 0.2415068 x 10Can be written as FP as 0.2415068 x 1099

Page 40: Number Systems & Operations Part I. Decimal Numbers (Base 10) People use decimal numbers. I hope you know this very well. However, let’s review: Ten digits.

Binary FP NumbersBinary FP Numbers

The format defined by ANSI/IEEE Standard 754-The format defined by ANSI/IEEE Standard 754-19851985 Single-precisionSingle-precision Double-precisionDouble-precision Extended-precisionExtended-precision

Same basic formats except for the number of Same basic formats except for the number of bits.bits. Single-precision = 32 bitsSingle-precision = 32 bits Double-precision = 64 bitsDouble-precision = 64 bits (Double) Extended-precision = 80 bits(Double) Extended-precision = 80 bits

Page 41: Number Systems & Operations Part I. Decimal Numbers (Base 10) People use decimal numbers. I hope you know this very well. However, let’s review: Ten digits.

Single-Precision Floating-Point Single-Precision Floating-Point Binary NumbersBinary Numbers

Standard format:Standard format: Sign bit (S) – 1 bitSign bit (S) – 1 bit Exponent (E) – 8 bitsExponent (E) – 8 bits Mantissa or fraction (F) – 23 bitsMantissa or fraction (F) – 23 bits

S(1) E(8) F(23)

Single-precision FP Binary Number Format

Page 42: Number Systems & Operations Part I. Decimal Numbers (Base 10) People use decimal numbers. I hope you know this very well. However, let’s review: Ten digits.

Single-Precision Floating-Point Single-Precision Floating-Point Binary NumbersBinary Numbers

MantissaMantissa The binary point is understood to be to the left The binary point is understood to be to the left

of the 23 bits.of the 23 bits. Effectively, there are Effectively, there are 24 bits24 bits in the mantissa in the mantissa

because in any binary number the left most bit because in any binary number the left most bit is always 1. (say 001101100 is is always 1. (say 001101100 is 11101100.)101100.)

Therefore, this Therefore, this 11 is understood to be there is understood to be there although it does not occupy an actual bit although it does not occupy an actual bit position.position.

S(1) E(8) F(23)

Single-precision FP Binary Number Format

Page 43: Number Systems & Operations Part I. Decimal Numbers (Base 10) People use decimal numbers. I hope you know this very well. However, let’s review: Ten digits.

Single-Precision Floating-Point Single-Precision Floating-Point Binary NumbersBinary Numbers

ExponentExponent The eight bits represent a The eight bits represent a biased exponentbiased exponent

which is obtained by which is obtained by adding 127adding 127.. The purpose of the bias is to allow very large The purpose of the bias is to allow very large

or very small numbers without requiring a or very small numbers without requiring a separate sign bit for the exponents.separate sign bit for the exponents.

The biased exp allows a range of actual exp The biased exp allows a range of actual exp values from -126 (00000001values from -126 (0000000122) to +127 ) to +127

(01111111(0111111122)) S(1) E(8) F(23)

Single-precision FP Binary Number Format

Page 44: Number Systems & Operations Part I. Decimal Numbers (Base 10) People use decimal numbers. I hope you know this very well. However, let’s review: Ten digits.

Single-Precision Floating-Point Single-Precision Floating-Point Binary NumbersBinary Numbers

Not easy, is it? Let’s see an example.Not easy, is it? Let’s see an example.ex: ex: 101101001000110110100100012 2 (assumption: positive number)(assumption: positive number)

It can be expressed as 1 plus a It can be expressed as 1 plus a fractional binary numberfractional binary number. .

Hence:Hence:

1011010010001 = 1.1011010010001 = 1.011010010001011010010001 x 2 x 21212

The exponent,12, is expressed as a biased exponent as followed:The exponent,12, is expressed as a biased exponent as followed:

12+127 = 139 = 1000101112+127 = 139 = 10001011

Therefore, we get:Therefore, we get:

0 10001011 01101001000100000000000

Page 45: Number Systems & Operations Part I. Decimal Numbers (Base 10) People use decimal numbers. I hope you know this very well. However, let’s review: Ten digits.

Single-Precision Floating-Point Single-Precision Floating-Point Binary NumbersBinary Numbers

Let’s do the opposite way: Let’s do the opposite way: To evaluate a binary number in FP format.To evaluate a binary number in FP format. General formula:General formula:

Number =Number = (-1)(-1)SS(1+(1+FF)(2)(2EE-127-127))ex:ex:

NumberNumber = (-1)(1.10001110001)(2 = (-1)(1.10001110001)(2145-127145-127))= (-1)(1.10001110001)(2= (-1)(1.10001110001)(21818))

= = -1100011100010000000-110001110001000000022

= = -407,680-407,6801010

1 10010001 10001110001000000000000

Page 46: Number Systems & Operations Part I. Decimal Numbers (Base 10) People use decimal numbers. I hope you know this very well. However, let’s review: Ten digits.

Single-Precision Floating-Point Single-Precision Floating-Point Binary NumbersBinary Numbers

Let’s review:Let’s review: The exponent can be any number between The exponent can be any number between

-126 to +128; that means extremely large and -126 to +128; that means extremely large and small numbers can be expressed.small numbers can be expressed.

Say, a 32-bit FP number can replace a binary Say, a 32-bit FP number can replace a binary integer number having 129 bits.integer number having 129 bits.

Distinctive point:Distinctive point: Because the exponent Because the exponent determines the position of the binary point, determines the position of the binary point, numbers containing both integer and numbers containing both integer and fractional parts can be represented.fractional parts can be represented.

Page 47: Number Systems & Operations Part I. Decimal Numbers (Base 10) People use decimal numbers. I hope you know this very well. However, let’s review: Ten digits.

Single-Precision Floating-Point Single-Precision Floating-Point Binary NumbersBinary Numbers

There are 2 exceptions to the format for There are 2 exceptions to the format for FP numbers:FP numbers: The number The number 0.00.0 is represented by all 0s. is represented by all 0s.

InfinityInfinity is represented by all 1s in the is represented by all 1s in the exponent and all 0s in the mantissa.exponent and all 0s in the mantissa.

x 00000000 00000000000000000000000

x 11111111 00000000000000000000000

Page 48: Number Systems & Operations Part I. Decimal Numbers (Base 10) People use decimal numbers. I hope you know this very well. However, let’s review: Ten digits.

Let’s Practice…Let’s Practice…

Convert the decimal number 3.248x10Convert the decimal number 3.248x1044 to to a single-precision floating-point binary a single-precision floating-point binary numbernumber


Recommended