170 likes | 391 Views
Numbers and Number Systems. Instructor : Eng. Haya Sammaneh. Real World. Computer. Data. Data. Dear Mom:. Keyboard. 10110010…. Digital camera. 10110010…. Introduction. Input device. Number Systems. Decimal -- 10 symbols (0,1,2,3,4,5,6,7,8,9) Binary -- 2 symbols (0,1)
E N D
Numbers and Number Systems Instructor : Eng. Haya Sammaneh
Real World Computer Data Data Dear Mom: Keyboard 10110010… Digitalcamera 10110010… Introduction Input device
Number Systems • Decimal -- 10 symbols (0,1,2,3,4,5,6,7,8,9) • Binary -- 2 symbols (0,1) • Octal -- 8 symbols (0,1,2,3,4,5,6,7) • Hexadecimal -- 16 symbols (0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F) , A = 10 , B = 11 ….F = 15
Converting with fraction, examples • Binary to Decimal Ex: (1101.1)2 1*23 + 1*22 + 0*21 + 1*20 + 1*2-1 = (13.5)10 • Octal to Decimal Ex: (673)8 6* 82 + 7*81 + 3*80 = (443)10 • Hexadecimal to Decimal Ex. (A9C)16 A* 162 + 9*161 + C * 160= 10* 162 + 9*161 + 12 * 160 =(2788)10
Converting, example • Binary to Octal Ex: (011011.101100)2(33.54)8 • Binary to Hexadecimal Ex: (11111011.11011000)2(FB.D8)16 • Hexadecimal to Binary Ex. (A3.B)16 (10100011.1011)2
Converting, example • Decimal to Binary EX: (12.3)10 (1100.01001)2 12 / 2 = 6 ( Remainder 0 (right) ) 6 / 2 = 3 ( Remainder 0 ) 3 / 2 = 1 ( Remainder 1 ) 1 / 2= 0 ( Remainder 1 (left)) 0.3 * 2 = 0.6 (left) 0.6 * 2 = 1.2 0.2 * 2 = 0.4 0.4 * 2 = 0.8 0.8 * 2 = 1.6 (right) Using the same method to convert the Decimal number to any base.
Signed Numbers • In general a N-bit integer can store numbers in the range of -2N-1 -1 to 2N -1
Ways to represent negatives • Negative integers are stored via two’s complement representation • 1’s complement • reverse the bits to get the negative • Ex: 1101 1’s complement 0010 • 2’s complement • It happens by reversing the bits (1’s complement) then adding 1. • Ex: 1101 2’s complement 0011 • Get 1’s complement 0010 • then add 1 0011
0 + 0 = 0 0 + 1 = 1 Overflow: If there is not enough room to hold the result correctly. If the two numbers are of opposite signs, no overflow can occur. (Why not?) multiplication 0 * 0 = 0 0 * 1 =0 1 * 0 = 0 1 * 1 = 1 1 + 0 = 1 1 + 1 = 0 and carry 1 Binary arithmetic – addition and multiplication (Result is smaller than one of them)
Concepts of bit, byte and word • Bit is the smallest data item in computers (short for "binary digit" . Each data item, or bit, can assume either the value 0 or the value 1. • Computer circuitry performs various simple bit manipulations, such as examining the value of a bit, setting the value of a bit and reversing a bit (from 1 to 0 or from 0 to 1). • Bytes are composed of eight bits which is the smallest grouping of numbers . Large amounts of memory are indicated in terms of kilobytes (1,024 bytes), megabytes (1,048,576 bytes), and gigabytes (1,073,741,824 bytes). • Words: The size of a word varies from one computer to another, depending on the CPU. For computers with a 16-bitCPU, a word is 16 bits (2 bytes). On large mainframes, a word can be as long as 64 bits (8 bytes) or 128 bit (16 byte). • Some computers and programming languages distinguish between short-words and long-words. A short-word is usually 2 bytes long, while a long-word is 4 bytes.
Standard Alphanumeric Formats • Problem : Representing text strings, such as “Hello, world”,in a computer • The standards for representing letters (alpha) and numbers • ASCII – American standard code for information interchange • Unicode
Character Code :ASCII and Unicode • Why do computers use numbers for the names of letters? • Because they store all information in number form. • Technical detail: they store information as ‘bytes’; each ‘byte’ consists of 8 ‘bits’; each ‘bit’ is either the number ‘0’ or ‘1’’
Character Code :ASCII and Unicode • ASCII and Unicode are two computer ‘languages’ for naming letters • The ASCII name for ‘a’ is ‘61’ • The Unicode name for ‘a’ is ‘U+0061’
ASCII Reference TableControl , Numeric, Alphabetic, Punctuations Codes 7416 111 0100
ASCII • Most widely used coding scheme • Computer systems can represent up to 256 letters • Technical detail: with one 8-bit byte (28 = 256) • ASCII only uses 7 bits (27 = 128) • The first 32-127 are called ASCII letters (characters) • 1-32: That’s for control characters like the ‘option’ key.
ASCII Problem • No one agrees on what letters the numbers 128-256 stand for.
Unicode: fixing the ASCII problem • Most common 16-bit form represents 65,536 characters. • Multilingual: These characters cover the principal written languages of the Americas, Europe, the Middle East, Africa, India, Asia, and Pacifica.