90 likes | 169 Views
CSE 2353 Spring 2009. Number Systems. Number Systems. Normal everyday math is in base 10 (decimal numbers) Why? Computers function in base 2 (binary numbers) Why? When interpreting computer data, humans often use base 8 (octal) or base 16 (hexadecimal) Why?. Number Systems.
E N D
CSE 2353 Spring 2009 Number Systems SMU - Dunham
Number Systems • Normal everyday math is in base 10 (decimal numbers) • Why? • Computers function in base 2 (binary numbers) • Why? • When interpreting computer data, humans often use base 8 (octal) or base 16 (hexadecimal) • Why? SMU - Dunham
Number Systems • Decimal numbers: 0,1,2,…,9 • Binary numbers: 0,1(Bit) SMU - Dunham
Number Systems • Octal numbers: 0,1,…,7 Group binary by threes • Hexadecimal numbers: 0,1,2,…,9,A,B,C,D,E,F Group binary by fours SMU - Dunham
In Class Exercises • Write the first 10 (in decimal) numbers in each number system. • Convert 110010 (binary) to decimal and octal and hexadecimal (Algorithm p 117). • Convert 3545 (decimal) to binary (Algorithm p116) and octal and hexadecimal • Convert 724 (octal) to binary and decimal and hexadecimal • Convert 5CE (hexadecimal) to binary and decimal and octal SMU - Dunham
How is Data Represented? • What does 01010111 mean? • If an instruction, then the opcode indicates what it is • If not an instruction then must be interpreted differently: • Integer - Based on number system used by machine and instruction • Real - Based on how real numbers are stored for this machine and instruction • Character - Based on encoding scheme (ASCII, EBCDIC) SMU - Dunham
Basic Integer Number Systems • Unsigned: 0 to • Sign Magnitude: to • High order bit indicates sign (0-positive; 1-negative) • Low order (n-1) bits indicates “number” • One’s Complement: • Positive same as sign magnitude • Negative number obtained by inverting all bits • Same range as sign magnitude SMU - Dunham
Basic Integer Number Systems • Two’s Complement • Range: to • Positive same as sign magnitude • Leftmost bit is sign (0-positive, 1-negative) • Negative number: Invert bits and add 1 • 8088/8086 • Excess • Same range as two’s complement • Leftmost bit is sign (0-negative, 1-positive) SMU - Dunham
Why Different Number Systems? • Range supported • Ease of operations • Number of zeros SMU - Dunham