CPU Data Types Chapter 3 Integer Real Numbers

CPU Data Types Chapter 3 Integer Real Numbers Character Boolean Memory Address Cis 303 a_chapt 03 -2. ppt

Integer • Whole numbers • No decimal places • Unsigned integers • Use entire by ( 8 or 6 bits) for number • Lowest number is zero (0) • Signed integers • Use high order bit for + or – sign • Octal machines have 5 bits for number (out of 6) Excess notation • Hex machines have 7 bit for number (out of 8) Excess notation Cis 303 a_chapt 03 -2. ppt

Integer Octal 6 BIT number Weight value All positions = “ 1” (“ON”) Unsigned 32 16 8 4 2 1 ----63 Cis 303 a_chapt 03 -2. ppt X X X 32 16 8 4 2 1 1 1 1 Signed Not counted: used for sign 16 8 4 2 1 ----31

Integer Hexadecimal 8 BIT number X Weight value All positions = “ 1” (“ON”) Unsigned 128 64 32 16 8 4 2 1 ----255 Cis 303 a_chapt 03 -2. ppt X X X 128 64 32 16 1 1 X X 8 4 2 1 1 Signed Not counted: used for sign 64 32 16 8 4 2 1 ----127 1

Arithmetic Operations Addition Subtraction Multiplication Division Cis 303 a_chapt 03 -2. ppt

Addition Add two numbers Decimal Binary bit weights 6 +5 ---1110 0101 ------10112 1 + 2 + 8 = 1110 Cis 303 a_chapt 03 -2. ppt

Subtraction Subtract two numbers Decimal Binary bit weights 6 - 5 ---110 0110 - 0101 * ------00002 1 + 0 + 0 = 110 1 ? 2 0110 -0101 ------- 5 3 Borrow 1 from 2 s position add to 1 s position 0101 ------6 Subtract 4 s position Subtract 8 s position 0101 -0101 ------0000 Cis 303 a_chapt 03 -2. ppt 4 Subtract 2 s position Subtract 1 s position 0101 ------00 0101 ------0 7 Answer is: 6 -5 ----0

Complements • Binary numbering scheme • Ones (1) become zero (0) • Zeros (0) become ones (1) 0 1 2 3 4 5 6 7 8 9 A B C D E F Cis 303 a_chapt 03 -2. ppt Octal Hexadecimal 000 = 111 001 = 110 010 = 101 011 = 100 = 011 101 = 010 110 = 001 111 = 0000 = 0001 = 0010 = 0011 = 0100 = 0101 = 0110 = 0111 = 1000 = 1001 = 1010 = 1011 = 1100 = 1101 = 1110 = 1111 1110 1101 1100 1011 1010 1001 1000 0111 0110 0101 0100 0011 0010 0001 0000

Two’s Complement Computers MULTIPLY, SUBTRACT and DIVIDE by ADDITION • Binary numbering scheme • Used to work with negative numbers • Ones (1) become zero (0) • Zeros (0) become ones (1) • Data is signed if: • Variable data type was defined as signed in the program • The number is converted in the program • The computer does a Subtract or Divide • Formula for conversion • Original binary number • Compliment the number • Ones to Zeros • Zeros to Ones • Add binary one to lowest position • High order carry's are discarded Cis 303 a_chapt 03 -2. ppt

Two’s Complement Add two numbers Decimal Binary bit weights 6 +5 ---1110 0101 ------10112 1 + 2 + 8 = 1110 Cis 303 a_chapt 03 -2. ppt

Two’s Complement Subtract two numbers Decimal Binary 11 6 - 5 ---110 0110 +1011 * ------00012 Binary bit weights 1 + 0 + 0 = 110 * Two’s Compliment of 5 5= 0101 Original Compliment Add one 1010 1 -------1011 Two’s compliment Cis 303 a_chapt 03 -2. ppt

Summary Computers do Subtraction And Division Using Addition and Two’s Compliment Cis 303 a_chapt 03 -2. ppt
- Slides: 12