You are on page 1of 45

MMW111 – Group 6

Topics:
1. Integers in Computer
2. Logic and Computer Addition
Topic Outline
• Binary Integers
▫ Methods in Computing Binary of Integers
 Sign bit and Magnitude
 1’s and 2’s Compliment
▫ Integer Arithmetic
• Boolean Algebra
▫ Logic (AND, OR, EXOR/XOR)
▫ Theorems, Postulates and Laws
Number System Theory
Numerical System Computer System
• Based on counting using an • States that the meaning of
alphabet and operations. digits must be expanded
• The decimal number system beyond mere counting,
uses the alphabet quantities and values.
{0,1,2,3,4,5,6,7,8,9}, called • Regularly use numeral systems
digits. of bases other than 10. (e.g.
• And the basic operations add, Base 2 (binary), Base 8 (octal),
subtract, multiply and divide. and Base 16 (hexadecimal)
Remember:
• The key to understanding
computers lies in unlearning that
the digit 1 means one and only
one, and learning that the digit 1
identifies something, which may
not be a number at all.
Integers in Computer
Binary Representation
of Integers
Binary Representation of Integers
• Integer is used to refer to any data type which
can represent some subset of the mathematical
integers. These are also known as integral data
types.
Note:
• Binary number can be represented only
by using 0’s and 1’s.
• Cannot use the sign (-) to denote the
negative number or (+) to denote the
positive number.
• Even the decimal point (.) cannot be
used.
Byte
• A byte represents eight bits, and is the most
commonly used term relating to the amount of
information stored within a computer’s
memory. The term doesn’t refer to “eight bits”
in a loose, simply mathematical sense, but to a
specific set of eight bits which operate as a
cohesive unit within a computer system. The
byte was first named in 1956, during the design
of the IBM Stretch computer.
Bit
• A bit is just a smaller unit of information than a
byte. It reflects the basic logical process of a
transistor: a single unit of information reflecting
a zero (no charge) or a one (a completed,
charged circuit). There are eight bits in one byte
of information.
• It is also a distinction between two possible
states, e.g. 0 or 1, high or low, off or on, etc.
Representation of Binary integers
in Computer
 1 byte = 8 bits
 2 bytes = 16 bits
 4 bytes = 32 bits Note: Use hexadecimal to compute
 8 bytes = 64 bits
Conversion Table
Decimal Binary Octal Hexadecimal

0 0000 0 0
1 0001 1 1
2 0010 2 2
3 0011 3 3
4 0100 4 4
5 0101 5 5
6 0110 6 6
7 0111 7 7
Conversion Table
Decimal Binary Octal Hexadecimal

8 1000 10 8
9 1001 11 9
10 1010 12 A
11 1011 13 B
12 1100 14 C
13 1101 15 D
14 1110 16 E
15 1111 17 F
Hexadecimal notation
Hexadecimal Binary Hexadecimal Binary

0 0000 8 1000
1 0001 9 1001
2 0010 A 1010
3 0011 B 1011
4 0100 C 1100
5 0101 D 1101
6 0110 E 1110
7 0111 F 1111
Methods in Computing Binary of
Integers
• Sign and magnitude method
• One’s (1’s) complement method
• Two’s (2’s) complement method
1) Sign and Magnitude Method
 16 bits used to represent integers
 Most significant bit (Leftmost bit) – indicated sign of
the number
 If negativity the leftmost bit is 1
 If positivity the leftmost bit is 0
For Example:
1. So, the binary number is (11110). If we take the size
of the word is 1 byte, then the number is 30 will be
represented as
 
= 00011110
2) One’s Complement Method
• Positive number is represented as same as
the binary number.
• If the number is negative, then we need to
find one’s complement of a binary number
• The one’s complement of a binary number
will replace every 0 with 1 and vice versa
For example:
1. Find the 1-byte integer representation of -55

= The binary number is 110111


“Add two zeros in the leftmost bit”
 1-byte representation is 00110111
 The given number is negative; hence we need to calculate one’s
complement
 One’s complement of 0011011 is 11001000
00110111 (Convert 0 into 1 and 1 into 0)
= 11001000
 Thus, the 1-byte representation of number -55 is 11001000
3) Two’s Complement Method
 Positive number is represented as the binary number
 If the number is negative, then we need to calculate
two’s complement binary number
 The two’s complement of a binary number is
calculated by adding 1 to its one’s compliment.
For example:
1. Find the 2 bytes integer representation of -234
2 bytes = 16 bits
Convert 234 to binary
234 = 11101010
• Hence, the 2-byte representation is
0000000011101010
0000000011101010
1111111100010101 (1’s)
+1
1111111100010110 (2’s)
 The given number is negative; hence we need to
calculate the two’s complement.
 One’s complement of 0000000011101010 is
1111111100010101(convert 1 into 0 and 0 into 1)
Two’s Complement Representation
Decimal 2’s Decimal 2’s
-8 1000 0 0000
-7 1001 1 0001
-6 1010 2 0010
-5 1011 3 0011
-4 1100 4 0100
-3 1101 5 0101
-2 1110 6 0110
-1 1111 7 0111
Integer Arithmetic
•Addition
•Subtraction
•Multiplication
•Division
Integer Arithmetic
Addition Subtraction
• Overflow is when adding two • Is done by using the 2’s
numbers, it is possible to produce complement of the number
a result whose number of bits is that is to be subtracted.
one more than the number of bits • In short, subtraction is done
in the addends.
by using the addition
• For one’s complement
operation.
▫ The leftmost bit is added to the
rightmost bit
• For two’s complement
▫ In computer arithmetic, the
leftmost bit in the result is
disregarded or ignored (or
simply taken out).
Integer Arithmetic
Addition Subtraction
Integer Arithmetic
Multiplication Division
• Is done by following the • Is done by a repetition of 2’s
decimal method. complement subtraction until
• Could also be done by using the quotient is too small for
the 2’s complement. subtraction or is zero.
• The answer will be the total
number of subtraction cycle
plus the remainder.
Integer Arithmetic
Multiplication Division
Logic and Computer
Addition
•Combinational Logic
•Logic Gates
•Boolean Algebra
•Theorems, Postulates, and Laws
Computer Logic
• Is an aspect of computer design concerning the
fundamental operations and structures upon
which all computer systems are built.
Combinational Logic
•Logic Gates
•Truth Table
Logic Gates
• Inverter
A device that changes a low logic level to a high level and vice
versa.
• AND gate
A 2-input device with one output that is highly only when he
both inputs are high.
• OR gate
A 2-input device with one output that is high if either or both
of the inputs were high.
• Exclusive-OR/EXOR/XOR gate
A 2-input device with one output that is high if either input is
high but not both.
Truth Table – Inverter
A NOT A
0 1
1 0
Truth Table – AND Gate
A B A AND B
0 0 0
0 1 0
1 0 0
1 1 1
Truth Table – OR Gate
A B A OR B
0 0 0
0 1 1
1 0 1
1 1 1
Truth Table – XOR Gate
A B A XOR B
0 0 0
0 1 1
1 0 1
1 1 0
Computer System
Binary Numbers Hexadecimal Numbers
• Core of all computer
operations.
• It is unlike a decimal number,
which has ten digits.
• A binary number is made up of
only two digits: the 1’s and 0’s
Boolean Algebra
•Definition
•Theorems
•Postulate
•Laws
Boolean Algebra
• Is the mathematic of two-valued logic
• In the theorems and postulates we assume a
positive logic, i.e., low logic level is zero (0) and
high logic level is one (1).
• In Boolean, the value 0 is equivalent to False
and the value 1 is equivalent to True
Postulate
• Is a basic assumption that I accepted without
proof. In Boolean algebra, we have the
postulates for conjunction (AND), disjunction
(OR), and negation (NOT).
Postulate: Conjunction/AND (•)
A•B =C
0•0 0
0•1 0
1•0 0
1•1 1
Postulate: Disjunction/OR (+)
A+B =C
0+0 0
0+1 1
1+0 1
1+1 1
Postulate: Negation/NOT (¯)

Ā =C
ō 1
ī 0
End of Presentation
Presented and made by:
Group 6 – PH1Y1-1
Durano
Maglangit
Morden
Rosaldo
Wagan

You might also like