Chapter 2 Introduction to Number System & Data Formats.

94
Chapter 2 Introduction to Number System & Data Formats

Transcript of Chapter 2 Introduction to Number System & Data Formats.

Page 1: Chapter 2 Introduction to Number System & Data Formats.

Chapter 2

Introduction to Number System & Data Formats

Page 2: Chapter 2 Introduction to Number System & Data Formats.

Chapter 2:

• (-133)*33+44*14.5 • How to represent these data?• How to calculate them?• How about other characters?

Page 3: Chapter 2 Introduction to Number System & Data Formats.

Chapter 2: Introduction to Number System & Data Formats

• 2.1 Number System ( 数制 )

• 2.2 Computer Data Formats

Page 4: Chapter 2 Introduction to Number System & Data Formats.

2.1 Number System ( 数制 )

Page 5: Chapter 2 Introduction to Number System & Data Formats.

2.1 Number System( 数制 )

• 2.1.1 Digits (数)• 2.1.2 Positional Notation ( 位计数法)• 2.1.3 Conversion to Decimal• 2.1.4 Converting From Decimal• 2.1.5 Binary-Coded Hexadecimal• 2.1.6 Operation of Binary• 2.1.7 Three Forms of Binary Data

Page 6: Chapter 2 Introduction to Number System & Data Formats.

2.1.1 Digits ( 数 )

Page 7: Chapter 2 Introduction to Number System & Data Formats.

2.1.1 Digits ( 数 )

• A. Decimal( 十进制 ) (0—9)

• B. Binary (0----1)

• C. Octal( 八进制 ) (0—7)

• D. Hexadecimal( 十六进制 ) • (0—9,A,B,C,D,E,F)

Page 8: Chapter 2 Introduction to Number System & Data Formats.

2.1.1 Digits ( 数 )

• Example: A base 13( 以 13 为基, 13 进制 )numb

er contains 13 digits:

0—9,A(10),B(11),C(12)

Page 9: Chapter 2 Introduction to Number System & Data Formats.

2.1.2 Positional Notation ( 位计数法)

Page 10: Chapter 2 Introduction to Number System & Data Formats.

2.1.2 Positional Notation ( 位计数法)

• Example 1:Decimal 132 1( 百位 ) 3( 十位 ) 2( 个位 )

hundreds tens units position position position

power( 幂 ) 102 101 100

weight( 权 )100 10 1In a base N number system, the radix is N( 基

数 ) and the exponent (i) ( 指数 ) means the position.

Page 11: Chapter 2 Introduction to Number System & Data Formats.

2.1.2 Positional Notation ( 位计数法)

• Example 2:Binary 101 1 0 1

power( 幂 ) 22 21 20

weight( 权 )4 2 1Numeric value 1* 22 + 0* 21 + 1* 20 =5 In a base 2 number system, the radix is

2( 基数 ) and the exponent (i) ( 指数 ) means the position.

Page 12: Chapter 2 Introduction to Number System & Data Formats.

2.1.2 Positional Notation ( 位计数法)

• Special exampleBinary 1111 1 1 1 1

power( 幂 ) 23 22 21 20

weight( 权 ) 8 4 2 1Numeric value 8+4+2+1 =15

0-15 It can represent 16 different numbers.

Page 13: Chapter 2 Introduction to Number System & Data Formats.

2.1.2 Positional Notation ( 位计数法)

• Example 3:Decimal 1.025 1 . 0 2 5

power( 幂 ) 100 10-1 10-2 10-3(Ni)weight( 权 )1 0.1 0.01 0.001In a base N number system, the radix is N and

the exponent (i) ( 指数 ) means the position. If the position is right to the point( 小数点 ),the power is negative (N-i).

Page 14: Chapter 2 Introduction to Number System & Data Formats.

2.1.2 Positional Notation ( 位计数法)

• Summarize– A base N number system Xm-1Xm-2Xm-3……X0

. Y1Y2Y3……Yn

– Numeric value( 数值 ): Xm-1* Nm-1+Xm-2 * Nm-2+ ……X0

* N0

+Y1 *N-1 +Y2 *N-2 + …… Yn * N-n

Page 15: Chapter 2 Introduction to Number System & Data Formats.

2.1.3 Conversion to Decimal

Page 16: Chapter 2 Introduction to Number System & Data Formats.

2.1.3 Conversion to Decimal

• Summarize– A base N number system Xm-1Xm-2Xm-3……X0

. Y1Y2Y3……Yn

– Decimal Xm-1* Nm-1+Xm-2 * Nm-2+ ……X0

* N0

+Y1 *N-1 +Y2 *N-2 + …… Yn * N-n

Page 17: Chapter 2 Introduction to Number System & Data Formats.

2.1.3 Conversion to Decimal

• Example:• Hexadecimal: E6A.C2• Decimal: E*162+6*161+6*160+C*16-1+2*16-2

=14*162+6*161+6*160+12*16-

1+2*16-2

=3690+0.75+0.0078125 =3690.7578125

Page 18: Chapter 2 Introduction to Number System & Data Formats.

2.1.4 Converting From Decimal

Page 19: Chapter 2 Introduction to Number System & Data Formats.

2.1.4 Converting From Decimal

• Summarize– A base N number system Xm-1Xm-2Xm-3……X0

. Y1Y2Y3……Yn

– Decimal Xm-1* Nm-1+Xm-2 * Nm-2+ ……X0

* N0

+Y1 *N-1 +Y2 *N-2 + …… Yn * N-n

Page 20: Chapter 2 Introduction to Number System & Data Formats.

2.1.4 Converting From Decimal

• From conversion to decimal we can assume that if we can figure out how many Ni are there in a decimal number, we may convert it back to a base N number system.

Page 21: Chapter 2 Introduction to Number System & Data Formats.

2.1.4 Converting From Decimal

• Principle A:– To convert a decimal whole numb

er portion( 整数部分 ) to another number system, divide by the radix N ( 基数 ) and save the remainders( 余数 ).

Page 22: Chapter 2 Introduction to Number System & Data Formats.

2.1.4 Converting From Decimal

• Principle A:• Step 1: Divide the decimal number by

the radix (number base).

• Step 2: Save the remainder (first remainder is the least significant digit --最先得到的余数是最低有效位 )

• Step 3: Repeat steps 1 and 2 until the quotient( 商 ) is zero.

Page 23: Chapter 2 Introduction to Number System & Data Formats.

2.1.4 Converting From Decimal• Principle A:

•Example convert decimal number 14 to a base 4 number system

4 14 remainder = 2 (least significant)

4 3 remainder = 3 0 result = 32

Page 24: Chapter 2 Introduction to Number System & Data Formats.

2.1.4 Converting From Decimal• Principle A:

•Example convert decimal number 14 to a base 2 number system

2 14 remainder = 0 (least significant)

2 7 remainder = 1 2 3 remainder = 1 2 1 remainder = 1 0 result = 1110

Page 25: Chapter 2 Introduction to Number System & Data Formats.

2.1.4 Converting From Decimal

• Principle B:– To convert a decimal fractional po

rtion( 小数部分 ) to another number system, multiply it by the radix ( 基数 ) and the whole number portion( 整数部分 ) of the result is saved as a significant digit of the result.

Page 26: Chapter 2 Introduction to Number System & Data Formats.

2.1.4 Converting From Decimal

• Principle B:• Step 1: Multiply the decimal fraction by the

radix (number base)

• Step 2: Save the whole number portion of the result (even if zero) as a digit. The first result is written immediately to the right of the radix point ( 得到的第一个整数写在最靠近小数点左边的位置 ).

• Step 3: Repeat 1 and 2 until the fraction part of step 2 is zero

Page 27: Chapter 2 Introduction to Number System & Data Formats.

2.1.4 Converting From Decimal• Principle B:

•Example convert decimal number 0.125 to a base 4 number system

.125* 4 0.5 digit is 0

0.5* 4 2.0 digit is 2 result is 0.02

Page 28: Chapter 2 Introduction to Number System & Data Formats.

2.1.4 Converting From Decimal

•Principle B:–Note: Some numbers are never-ending . That is, a zero is never a remainder.

– For example converting 0.15 to a base 4 number system.

–Why ?

Page 29: Chapter 2 Introduction to Number System & Data Formats.

2.1.4 Converting From Decimal

• Example: convert 0.15 to a base 4 number system.

.15 0.4 * 4 * 4

0.6 digit is 0 1.6 digit is 1

0.6 * 4

2.4 digit is 2 result is 0.0212……

Page 30: Chapter 2 Introduction to Number System & Data Formats.

2.1.4 Converting From Decimal

• 0.0212……– Numeric value:– 0*4-1 + 2*4-2 + 1*4-3 + 2*4-4

– =0 + 0.125 + 0.015625 + 0.0078125

– = 0.1484375– ≈ 0.15

Page 31: Chapter 2 Introduction to Number System & Data Formats.

2.1.5 Binary-Coded Hexadecimal

Page 32: Chapter 2 Introduction to Number System & Data Formats.

2.1.5 Binary-Coded Hexadecimal

• How many different numbers can 4 binary numbers form ?

Page 33: Chapter 2 Introduction to Number System & Data Formats.

2.1.5 Binary-Coded Hexadecimal

• BCH codehexadecimal digit BCH code 0 1 0000 0001 2 3 0010 0011 4 5 0100 0101 6 7 0110 0111 8 9 1000 1001 A B 1010 1011 C D 1100 1101 E F 1110 11119E = 1001 1110

BCD

Page 34: Chapter 2 Introduction to Number System & Data Formats.

2.1.5 Binary-Coded Hexadecimal

• Principle:•We just use 4-bit binary to replace each hexadecimal digit and write down them in the same sequence. Note that there must be a space between each 4-bit binary.

Page 35: Chapter 2 Introduction to Number System & Data Formats.

2.1.5 Binary-Coded Hexadecimal

• Example:Hexadecimal :2 A C . 5BCH :0010 1010 1100 . 0101

BCH :0010 1110 . 0101 1011Hexadecimal : 2 E . 5 B

Page 36: Chapter 2 Introduction to Number System & Data Formats.

2.1.6 Operation of Binary

All the numbers are unsigned.

Page 37: Chapter 2 Introduction to Number System & Data Formats.

2.1.6 Operation of Binary

• Add Operation Rules:• 0+0 = 0• 0+1 = 1• 1+0 = 1• 1+1 = 0 submit( 进位 ) 1• 1+1+1 = 1 submit( 进位 ) 1

Page 38: Chapter 2 Introduction to Number System & Data Formats.

2.1.6 Operation of Binary

• Add Operation• 1101 + 1011

1 1 1 1 submit bit 1 1 0 1 add bit

+ 1 0 1 1 added bit 1 1 0 0 0 result

Page 39: Chapter 2 Introduction to Number System & Data Formats.

2.1.6 Operation of Binary

• Subtract Operation Rules• 0-0 = 0• 1-1 = 0• 1-0 = 1• 0-1 = 1 borrow( 借位 ) 1

Page 40: Chapter 2 Introduction to Number System & Data Formats.

2.1.6 Operation of Binary

• Subtract Operation• 11000100 – 00100101• 1 1 1 1 1 1 ( 借位 )

1 0 1 1 1 0 1 ( 借位后的被减数 ) 1 1 0 0 0 1 0 0 ( 被减数 )

- 0 0 1 0 0 1 0 1 ( 减数 ) 1 0 0 1 1 1 1 1

Page 41: Chapter 2 Introduction to Number System & Data Formats.

2.1.6 Operation of Binary

• Multiply Operation Rules• 0*0 = 0• 0*1 = 0• 1*0 = 0• 1*1 = 1

Page 42: Chapter 2 Introduction to Number System & Data Formats.

2.1.6 Operation of Binary

• Multiply Operation 1111 * 1101 1 1 1 1 * 1 1 0 1

1 1 1 1

0 0 0 0 1 1 1 1 1 1 1 1

1 1 0 0 0 0 1 1

Page 43: Chapter 2 Introduction to Number System & Data Formats.

2.1.6 Operation of Binary

• Divide Operation 0 0 0 1 1 1 1 0 1 1 0 1 1 0 0 0 1 1 1 0 1 1 0 0 1 0

1 1 0 1 1 0 1 0 1 1 1 1 1 0 0 0 1 1 0 1 1 0 1 1 0 1 1 1 1 1 0 1 1 0 1 0 1 0

Page 44: Chapter 2 Introduction to Number System & Data Formats.

2.1.6 Operation of Binary

• All the numbers are unsigned , so they are positive.

• How can we represent negative number in binary in a computer?

Page 45: Chapter 2 Introduction to Number System & Data Formats.

2.1.7 Three Forms of Binary Data

Page 46: Chapter 2 Introduction to Number System & Data Formats.

2.1.7 Three Forms of Binary Data

• Signed data can be represented in three forms.

•Original binary data ( 原码 )•Radix-1 complements ( 反码 )•Radix complements ( 补码 )

• We use byte-sized data in our examples.

Page 47: Chapter 2 Introduction to Number System & Data Formats.
Page 48: Chapter 2 Introduction to Number System & Data Formats.
Page 49: Chapter 2 Introduction to Number System & Data Formats.

2.1.7 Three Forms of Binary Data• Original binary data ( 原码 )

• 0 0 0 0 0 0 0 0

105 ---- 0 1101001-105 ---- 1 1101001

0 positive1 negative Numerical value (-127~+127)

Page 50: Chapter 2 Introduction to Number System & Data Formats.

2.1.7 Three Forms of Binary Data

• Original binary data ( 原码 ) 105 ---- 0 1101001-105 ---- 1 1101001

• Radix-1 complements ( 反码 )• 105 ---- 0 1101001• -105 ---- 1 0010110• 0 ---- 0 0000000• -0 ---- 1 1111111

Page 51: Chapter 2 Introduction to Number System & Data Formats.

2.1.7 Three Forms of Binary Data• Radix complements ( 补码 )

反码 radix-1 complement 补码 radix complement 105 0 1101001 0 1101001-105 1 0010110 1 00101110 0 0000000 0 0000000-0 1 1111111 0 0000000

Page 52: Chapter 2 Introduction to Number System & Data Formats.

2.1.7 Three Forms of Binary Data

• Example: -8• +8=00001000• 1000 (write number to

first 1)• 1111 (invert the remaining

bits)• -8= 1111 1000

Page 53: Chapter 2 Introduction to Number System & Data Formats.

2.1.7 Three Forms of Binary Data

• - 25

• + 25 = 0001 1001• - 25 (补)= 1110 0111

• - 39

• + 39 = 0010 0111• - 39 (补)= 1101 1001

Page 54: Chapter 2 Introduction to Number System & Data Formats.

2.1.7 Three Forms of Binary Data

• Negative signed numbers are stored in the two’s complement form. ( 负数以 2 进制的补码形式存储 )

• A simpler technique for two’s implement:– Write the number exactly as it appears from r

ight to left until the first one. Write down the first one, and then invert all the remaining bits.

Page 55: Chapter 2 Introduction to Number System & Data Formats.

2.1.7 Three Forms of Binary Data

• If we use radix complement to represent a negative data, we can change subtract operation to add operation.

Z = X – Y equal to Z 补 =X 补 + (-Y) 补

Page 56: Chapter 2 Introduction to Number System & Data Formats.

2.1.7 Three Forms of Binary Data

• Z = X – Y equal to Z 补 =X 补 + (-Y) 补

• Example 1: 64 -10 64-10 = 64 补 + (-10) 补

64 补 = 01000000 (-10) 补 =11110110 01000000+ 11110110 (right) 100110110 result = 00110110 = 54

Nature lost

Page 57: Chapter 2 Introduction to Number System & Data Formats.

2.1.7 Three Forms of Binary Data• Example 2: 34-68

• 34-68 = 34 补 +( -68) 补• 34 补 =00100010 ( -68) 补 =10111100 00100010 + 10111100 11011110 result = 11011110 = -34(right)

11011110( 补 )= 11011101( 反 ) = - 00100010( 原 ) =-34-1

Page 58: Chapter 2 Introduction to Number System & Data Formats.

• 10001101( 补 ) • = 10001100( 反 ) = - 01110011( 原 )• =-115

Page 59: Chapter 2 Introduction to Number System & Data Formats.

2.1.7 Three Forms of Binary Data

• You can turn to the reference book “Microcomputer Principle and Application” 《微机原理和应用》 page 9 for details.

Page 60: Chapter 2 Introduction to Number System & Data Formats.

2.1.7 Three Forms of Binary Data

• Z = X – Y equal to Z 补 =X 补 + (-Y) 补

• Example 1: 64 -10 64-10 = 64 补 + (-10) 补

64 补 = 01000000 (-10) 补 =11110110 01000000+ 11110110 (right) 100110110 result = 00110110 = 54

Nature lost

Page 61: Chapter 2 Introduction to Number System & Data Formats.

2.1.7 Three Forms of Binary Data

• Example 3: 127 +8127= 01111111 8=00001000

01111111+ 00001000

10000111 result = 135

OverflowError!

Page 62: Chapter 2 Introduction to Number System & Data Formats.

• 加法运算溢出– 当次高位向最高位产生进位,而最高位不向

前产生进位时, O = 1( 溢出)– 当次高位向最高位无进位,而最高位向前有

进位时, O = 1 (溢出)– 当最高位向前有进位时, C=1, 否则 C = 0

– 0 1 1 0 0 1 0 0 – + 0 1 1 0 0 1 0 0– 1 1 0 0 1 0 0 0 O=1 C=0

• 加法运算溢出– 当次高位向最高位产生进位,而最高位不向

前产生进位时, O = 1( 溢出)– 当次高位向最高位无进位,而最高位向前有

进位时, O = 1 (溢出)– 当最高位向前有进位时, C=1, 否则 C = 0

– 0 1 1 0 0 1 0 0 – + 0 1 1 0 0 1 0 0– 1 1 0 0 1 0 0 0 O=1 C=0

次高位最高位

Page 63: Chapter 2 Introduction to Number System & Data Formats.

• 加法运算溢出– 当次高位向最高位产生进位,而最高位不向

前产生进位时, O = 1( 溢出)– 当次高位向最高位无进位,而最高位向前有

进位时, O = 1 (溢出)– 当最高位向前有进位时, C=1, 否则 C = 0

– 1 0 1 0 1 0 1 1 – + 1 1 1 1 1 1 1 1– 1 1 0 1 0 1 0 1 0 O=0 C=1

Page 64: Chapter 2 Introduction to Number System & Data Formats.

2.2 Computer Data Formats

Page 65: Chapter 2 Introduction to Number System & Data Formats.

2.2 Computer Data Formats

• 2.2.1 ASCII Data• 2.2.2 BCD Data• 2.2.3 Byte-Sized Data• 2.2.4 Word-Sized Data• 2.2.5 Doubleword-Sized Data• 2.2.6 Real Numbers

Page 66: Chapter 2 Introduction to Number System & Data Formats.

2.2.1 ASCII Data

Page 67: Chapter 2 Introduction to Number System & Data Formats.

2.2.1 ASCII Data

• ASCII (American Standard Code for Information Interchange) represent alphanumeric characters in the memory of a computer system.

• ASCII use 8-bit(00H—FFH) represent alphanumeric characters in computer.

Page 68: Chapter 2 Introduction to Number System & Data Formats.

2.2.1 ASCII Data

• Table 1-7 on page 35 shows what is 00H—7FH representing.

• Table 1-8 on the same page shows extended ASCII code. Including what is 8FH—FFH representing.

• How to represent characters in other countries?

Page 69: Chapter 2 Introduction to Number System & Data Formats.

2.2.1 ASCII Data

• Many Windows-based applications use the Unicode system to store alphanumeric data and thus resolve the problem.

• Unicode system use 16-bit data to represent character.

• 0000H—00FFH is the same as ASCII code

• 0100H—FFFFH is used to store other special characters from other countries.

Page 70: Chapter 2 Introduction to Number System & Data Formats.

2.2.2 BCD Data

Page 71: Chapter 2 Introduction to Number System & Data Formats.

2.2.2 BCD Data

• BCD codedecimal digit BCD code 0 1 0000 0001 2 3 0010 0011 4 5 0100 0101 6 7 0110 0111 8 9 1000

1001

Page 72: Chapter 2 Introduction to Number System & Data Formats.

• 1MB 1M BYTE

8 Bit

8 Bit

Page 73: Chapter 2 Introduction to Number System & Data Formats.

2.2.2 BCD Data

• BCD data has two forms. One is packed and the other is unpacked.

• In all case, store the least-significant data first.( 规则 : 先存储最低有效位 )

• Packed BCD data are stored as two digits per byte 37-----0011 0111-----37H

• Unpacked BCD data are stored as one digit per byte

37-----0000 0011 0000 0111 -----0307H

Page 74: Chapter 2 Introduction to Number System & Data Formats.

2.2.3 Byte-Sized Data

Page 75: Chapter 2 Introduction to Number System & Data Formats.

2.2.3 Byte-Sized Data

• The weights of each binary-bit position

• Unsigned byte

• Signed byte

128

64 32 16 8 4 2 1

-128 64 32 16 8 4 2 1

Page 76: Chapter 2 Introduction to Number System & Data Formats.

2.2.3 Byte-Sized Data

• One byte contains 8 bits.• Byte-sized data are stored as

unsigned and signed integers.• Unsigned integers range in value

from 00H to FFH (0-255)• Signed integers range in value

from -128 to +127.

Page 77: Chapter 2 Introduction to Number System & Data Formats.

2.2.3 Byte-Sized Data

• Example of defining a byte-sized data:– unsigned– 0000 FE DATA1 DB 254– 0001 87 DATA2 DB 87H– 0002 47 DATA3 DB 71– Signed– 0003 9C DATA4 DB -100– 0004 64 DATA5 DB +100

Store address

Store value

All the data formats are based on a

8088 microprocessor, whose data width

is 8 bits.

Page 78: Chapter 2 Introduction to Number System & Data Formats.

2.2.4 Word-Sized Data

Page 79: Chapter 2 Introduction to Number System & Data Formats.

2.2.4 Word-Sized Data

• One word contains 16 bits. That is it is formed with two bytes of data.

• Word-sized data are stored as unsigned and signed integers. The difference between them is the weight of the highest position. For unsigned integers it is 32768 while signed is -32768.

Page 80: Chapter 2 Introduction to Number System & Data Formats.

• In Intel microprocessor, the least significant byte is stored in the lowest-numbered memory location, and the most significant byte is stored in the highest-numbered memory location.

• DATA DW 1234H 3002H

3001H3000H2FFFH

2.2.4 Word-Sized Data

12H34H

Memory width :

8 bit

Page 81: Chapter 2 Introduction to Number System & Data Formats.

2.2.4 Word-Sized Data

• Example:• Unsigned• 0000 09F0 DATA1 DW 2544• 0002 87AC DATA2 DW 87ACH• 0004 02C6 DATA3 DW 710• Signed• 0006 CBA8 DATA4 DW -13400• 0008 00C6 DATA5 DW +198

Page 82: Chapter 2 Introduction to Number System & Data Formats.

2.2.5 Doubleword-Sized Data

Page 83: Chapter 2 Introduction to Number System & Data Formats.

2.2.5 Doubleword-Sized Data

• One doubleword contains 32 bits. That is it is formed with two words or four bytes of data.

• Doubleword-sized data are stored as unsigned and signed integers. The difference between them is the weight of the highest position.

Page 84: Chapter 2 Introduction to Number System & Data Formats.

• In Intel microprocessor, the least significant byte is stored in the lowest-numbered memory location, and the most significant byte is stored in the highest-numbered memory location.

• DATA DD 12345678H

3003H

3002H3001H3000H

DATA DD 5678H ???

2.2.5 Doubleword-Sized Data

12H

34H

56H

78H

Page 85: Chapter 2 Introduction to Number System & Data Formats.

2.2.5 Doubleword-Sized Data

• Example :

• Unsigned• 0000 0003E1C0 DATA1 DD 254400• 0004 87AC1234 DATA2 DD

87AC1234H• 0008 00000046 DATA3 DD 70• Signed• 000C FFEB8058 DATA4 DD -1343400• 0010 000000C6 DATA5 DD +198

Page 86: Chapter 2 Introduction to Number System & Data Formats.

2.2.5 Doubleword-Sized Data

• Note : Byte-sized, word-sized, doubleword-sized data are standard form. We can use DB to define those nonstandard data.

• Example : Define 123456H• DB 56H,34H,12H• DD 123456H

What is the difference?

Page 87: Chapter 2 Introduction to Number System & Data Formats.

2.2.6 Real Numbers

Page 88: Chapter 2 Introduction to Number System & Data Formats.

2.2.6 Real Numbers

• In high-level language we often encounter number like 24.5. We call it real number or floating-point number( 浮点数 ).

• As we have noticed, 24.5 (2.45*101) contained two parts: significand ( 尾数 ) and exponent ( 指数 ).

• 4-byte real number is called single-precision and 8-byte double-precision.

Page 89: Chapter 2 Introduction to Number System & Data Formats.

2.2.6 Real Numbers

• Single-precision using a bias of 7FH

• Double-precision using a bias of 3FFH

S31

Exponent30-23

Significant22-0

S63

Exponent62-52

Significant51-0

Page 90: Chapter 2 Introduction to Number System & Data Formats.

2.2.6 Real Numbers

• The exponent is stored as bias exponent.

• For single-precision: bias exponent = exponent + 7FH

• For double-precision:bias exponent = exponent + 3FFH

Page 91: Chapter 2 Introduction to Number System & Data Formats.

2.2.6 Real Numbers

• Table 1.10 single-precision number(P41)

decimal binary normalized sign Biased exponent

significant

+12 1100 1.1*23 0 0111,1111+11

100 0000 0000 0000 0000 0000H

-12 1100 -1.1*23 1 10000010

+100 1100100

1.1001*26

0 01111111+110

100 1000 0000 0000 0000 0000H

Page 92: Chapter 2 Introduction to Number System & Data Formats.

2.2.6 Real Numbers

• Define single-precision data(32 bit)•DD / REAL4

• Define double-precision data(64 bit)

•DQ / REAL8

• Define extended precision data•REAL10

Page 93: Chapter 2 Introduction to Number System & Data Formats.

2.2.6 Real Numbers

• Examples:• Single-precision 0000 3F9DF3B6 NUMB1 DD 1.2340004 C1BB3333 NUMB2 REAL4 -23.4

• Double-precision0008 405ED9999999999A NUMB3 DQ(REAL8)

123.4

• Extended-precision0010 4005F6CCCCCCCCCCCCCD NUMB4

REAL10 123.4

Page 94: Chapter 2 Introduction to Number System & Data Formats.

2.2.6 Real Numbers

• Two exceptions to the rules for floating-point numbers.

• 0.0 is stored as all zeros.

• Positive infinity.

• Negative infinity.

S0

Exponent30-23 (ALL ONES)

Significant 22-0 (ALL ZEROS)

S1

Exponent30-23 (ALL ONES)

Significant 22-0 (ALL ZEROS)

S0

Significant 22-0 (ALL 0)

Exponent30-23 (ALL 0)