Title: Numbers and Number Systems
1Numbers and Number Systems
- Instructor Eng. Haya Sammaneh
2Introduction
Input device
3Number 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
4Converting with fraction, examples
- Binary to Decimal
- Ex (1101.1)2 ? 123 122 021 120 12-1
(13.5)10 - Octal to Decimal
- Ex (673)8 ? 6 82 781 380 (443)10
- Hexadecimal to Decimal
- Ex. (A9C)16 ? A 162 9161 C 160
- 10 162 9161 12
160 (2788)10
5Converting, 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
6Converting, 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.
7Signed Numbers
- In general a N-bit integer can store numbers in
the range of -2N-1 -1 to 2N -1
8Ways to represent negatives
- Negative integers are stored via twos complement
representation - 1s complement
- reverse the bits to get the negative
- Ex 1101 ? 1s complement ? 0010
- 2s complement
- It happens by reversing the bits (1s complement)
then adding 1. - Ex 1101 ? 2s complement ? 0011
- Get 1s complement ? 0010
- then add 1 ? 0011
9Binary arithmetic addition and multiplication
- 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
(Result is smaller than one of them)
10Concepts 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-bit CPU, 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.
11Standard 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
12Character 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
13Character 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 U0061
14ASCII Reference TableControl , Numeric,
Alphabetic, Punctuations Codes
7416 111 0100
15ASCII
- 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 Thats for control characters like the
option key.
16ASCII Problem
- No one agrees on what letters the numbers 128-256
stand for.
17Unicode 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.