Documente Academic
Documente Profesional
Documente Cultură
• Simplest way
- Unary representation
• For example, 4 ~ 1111
• Obvious Problem
- cumbersome when working with large
numbers.
• Also studied, Roman Numerals
Types of Number Systems
A number system defines how a number can be
represented using distinct symbols.
Categorized into two groups:
positional
& non-positional systems.
In a positional number system
each symbol represents different value
depending on the position they occupy in a
number.
Example
Decimal, Binary, Hexadecimal & Octal
1/15/2020
Types of Number Systems
In non-positional number system
each symbol represents the same
value regardless of its position
Example : Unary
Question
What About Roman Numerals?
- Hybrid of Positional & Non-positional
Why?
Look at IX, XI, XII
Decimal Number System
• Till now, comfortable working with 0,1,2,…,9
• Referred as decimal numbers
– Ten symbols: 0,1, ….9
– Operations are systematic – i.e. algorithmic
• Implementation issues:
– Hard to store
• ENIAC (First electronic computer) used 10 vacuum tubes / digit
– Hard to transmit
• Need high precision to encode 10 signal levels on single wire
– Messy to implement digital logic functions
Addition, multiplication, etc.
1/15/2020
Binary system
0.5V
1/15/2020 6
0.0V
Bits & Data Types
• Symbolically we represent –
- presence of voltage as ‘1’
- absence of voltage as ‘0’
• Each 0 & each 1 is referred to as a bit.
• Bit – short form for binary digit.
Binary Number System
• Two digits: 0,1 MSB
Positional number system
• A nibble is 4 bits
• A byte is 8 bits
LSB
• A word is 32 bits or 4 bytes
• Long word = 8 bytes = 64 bits
• Quad word = 16 bytes = 128 bits
• Programming languages use these
standard number of bits when organizing
data storage and access.
1/15/2020 8
Bits
• Important
- to be able to identify uniquely a large
number of distinct values.
• Voltage on one wire can represent
uniquely one of only two things.
• To identify many things
- necessary to combine bits
Bits & Data Types
• If we use eight bits
(corresponding to the voltage present
on eight wires)
• We can uniquely identify at most
- 2^8 (256) numbers
• In general, with k bits
- at most 2^k things can be uniquely
identified.
Data Types
• Once we represent information
Important
- How to operate on it?
- A representation is a data type
if there are operations in the computer
that can operate on information
encoded in that representation.
Data Types
Two important Data Types
- Representing numbers
- Representing characters
• Unsigned Integers
• We know
12 = 0.2^4 + 1.2^3 + 1.2^2 + 0.2^1 + 1.2^0
~ 01100
Integer Data Types
Important, with k bits
- 0 to 2^k – 1 integers can be
represented.
• For example, with 5 bits
- we can represent integers from 0 to 31.
- Unsigned Integers
Signed Integers
• Consider 5 bit code
- we know 32 things can be uniquely
identified.
• We can choose to represent
- positive integers from 1 to 15
- negative integers from -1 to -15
We still have two 5-bit codes unassigned.
Important: 0 ~ 00000
Signed Magnitude
• Observe
0 to 15 (0 to 2^(k-1)-1) have leading 0.
• i.e., positive integers have 0 as a
leading bit.
• For representing negative integers
- put leading bit 1 instead of 0
• Now, 12 ~ 01100,
So -12 ~ 11100
Note: MSB is used to indicate the sign
That leaves two values: one for 0
Signed Integers Cont…
Example: 3 bits
Signed
Magnitude
000 +0
001 +1
010 +2
011 +3
100 -0
101 -1
110 -2
111 -3
1/15/2020 16
Limitations of SM
Problems with sign-magnitude representation!
- Two representations of zero (+0 and –0)
- Arithmetic circuits are complex to
implement (hardware complexity is more)
- Unexpected results
(if we perform arithmetic operations)
Example : Try 2 + (-1)
010
+ 101
1/15/2020
111 = - 3 ???
17
1’s complement
• A negative number is represented by
- taking the representation of positive
number having the same magnitude
& ‘flipping’ all the bits.
• For example, 12 ~ 01100 so,
-12 ~ 10011
• Observe,
0 and - 0 has different representations
This representation was used in some early
computers
Contd…
1’s
Signed
b2b1b0 Complemen
Magnitude
t
000 +0 +0
001 +1 +1
010 +2 +2
011 +3 +3
100 -0 -3
101 -1 -2
110 -2 -1
19
111 -3 -0