0% found this document useful (0 votes)
16 views146 pages

Plus One State Numbers System and Boolean Algebra08!04!2023-5

Uploaded by

aleenataw195
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views146 pages

Plus One State Numbers System and Boolean Algebra08!04!2023-5

Uploaded by

aleenataw195
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 146

DATA REPRESENTATION&

BOOLEAN ALGEBRA
NUMBER SYSTEM
A number system is a systematic way to represent
numbers. The number of symbols used in a number system
is called base or radix of a number system.
-
NUMBER SYSTEM CLASSIFICATION

1. Decimal Number System -


2. Binary Number System -
-
3. Octal Number System
-
4. Hexadecimal Number System
Decimal Number System -

The decimal number system involves ten symbols 0, 1, 2, 3, 4, 5, 6, 7, 8 and 9


-
to form a number. Since there are 10 symbols in this number system, its base
is 10. Therefore, the decimal number system is also known as base-10 number
-
system.

(23470
-
Binary Number System -
A number system which uses only two symbols 0 and 1 to form a
-
number is called binary number system. Bi means two. Base of this
number system is 2. So it is also called base-2 number system. We
-
use the subscript 2 to indicate that the number is in binary.

(010)2
-

-
OCTAL Number System -
A number system which uses eight symbols 0, 1, 2, 3, 4, 5, 6 and 7
-

to form a number is called octal number system. Octa means eight,


hence this number system is called octal. Base of this number
system is 8 and hence it is also called base-8 number system
-

GGD f
-
Hexadecimal Number System -
A number system which uses 16 symbols 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
-

A, B, C, D, E and F to form a number is called-


hexadecimal
-

number system. Base of this number system is 16 as there are


-

sixteen symbols in this number system. Hence this number


system is also called base-16 number system.

- O
-
-

#F2),
-
( . 615)0
,
= (?
2 2
Lo
.

10110

101
-
-

I
- 20 .
625X
!

2,
Epo
000
- - 1
,
Number conversions
=
1. Decimal to Binary(2)
-

2. Decimal to Octal Cr
-

3. Decimal to Hexadecimal (16)


=>
4. Binary to Decimal
5. Octal to Decimal
6. Hexadecimal to Decimal
7. Binary to Hexadecimal
8. Hexadecimal to Binary
9. Binary to Octal
10. Octal to Binary
11. Hexadecimal to Octal
12. Octal to Hexadecimal
Decimal to Binary

25,0 = (1
72 z

.

Good bo
!
Decimal fraction to Binary

(5) ,0
= (?
)

(11000D 25 x
0
2
.

-
-


-

0 .

08X
Decimal to Octal
- es
(350
-
?.. 83
-
=
C

(3z
=
-
-
Decimal to Hexadecimal
it 16
Do =
(2 I 164-150)
0-1

[Fis
=
Binary to decimal

(1112 = C ? Do

2
= 1x22 + Wet I
= i+ 2+ 1
=
Octal to Decimal

(2 +g = (1)
,

82g/ 0
g
↑ 2)
1x8+ 2x8' +
Tx0
=

= 62 + 16 + 1 =
2)
10
Hexadecimal to Decimal

256x18
(A2D, = ( 2.)
,0

i
=
Ax(6"+ 2x16' + 1x
(2593)
=

2560 + 32 +
n =
= 6
=
Octal to Binary
421
-

521
-
008 10
(26) = (?
)
O 5
10016 110
726

2018 711/
-


3011 (11010110)
-

< 100
Binary to Octal

(011( = C? )
,

L 11 I

(67)
-
Hexadecimal to Binary 84 21
8421 8321 Et En

O 08 5
--

0101 A40)
1010

1021
0110 BLID
100016
70111 C((2)
1100
20018

g 1000 D(B) 110


30011
9 1001 EUD 1110
50 , 00
F(5) 111 I
Binary to Hexadecimal
Octal to Hexadecimal
Hexadecimal to Octal

-
Binary Addition
Rules are

0+0=0
1+0=1
0+1=1
1+1=0 carry 1
(53177 =
(32
5317
↓ 101
On I
(10101100111)
2 oo1
111
-

GOOD
= r 521
010
/ (7) 101
275 --
Binary Subtraction Rules

0-0=0
1-0=0
0-1=1 borrow 1
1-1=0
DATA REPRESENTATION

1. Representation of Numbers
2. Representation of Characters
3. Representation of Audio,Video and Image
1. REPRESENTATION OF NUMBERS

I. Representation of Integers
Ii. Representation of Floating point Numbers
-
I. Representation of integers

a. Sign and Magnitude Representation - ~

b. 1’s Complement Representation -


c. 2’s Complement Representation -
1. Sign and Magnitude Representation
In this method, first bit from left (MSB) is used for representing
sign of integer and remaining 7-bits are used for representing
magnitude of integer. For negative integers sign bit is 1 and for
positive integers sign bit is 0. Magnitude is represented as 7 bit
binary equivalent of the integer.
Eg : RepresentE
+ 23 in sign and magnitude form

10111 23
Binagf --
24-1


T but
0010111-
G-1
=

Sign and magnitude from


It
o
=
(200101112 2

o - 1
-

-
Represent -105 in sign and magnitude form
1’s complement representation
In this method, first find binary equivalent of absolute value of
integer. If number of digits in binary equivalent is less than 8,
provide zero(s) at the left to make it 8-bit form. 1’s complement
of a binary number is obtained by replacing every 0 with 1 and
every 1 with 0 .
-

237
-25 in 1’s Complement form and 2's from
Eg: Represent -65
=

Bina = 1011/

8bit =
000 !
is =
(11101000)
2 =
11101000 Is
(11 0100D
T
+ 0 1 00l
-2
-
2’ s complement representation
In this method, first find binary equivalent of absolute value of
integer and write it in 8- bit form. If the number is negative it is
represented as 2’s complement of 8-bit form binary. If the
number is positive 8-bit form binary itself is the representation.
2’s complement of a binary number is calculated by adding 1 to
its 1’s complement.
Represent -38 in 2’s complement form.
Subtraction Using 1’s Complement

Subtract 1002 from 10102 Using 1’s Complement


Subtraction Using 2’s Complement

Subtract 1002 from 10102 Using 2’s Complement


b. Representation of floating point numbers
A floating point number / real number consists of an integer part and a
fractional part. A real number can be written in a special notation called
the floating point notation. Any number in this notation contains two
-

parts, mantissa and exponent.


-

For example, 25.45 can be written as 0.2545×102, where 0.2545 is the


-

mantissa and the power 2 is the exponent. (In normalised floating point
notation mantissa is between 0.1 and 1). Similarly -0.0035 can be written
as -0.35x10-2, where -0.35 is mantissa and -2 is exponent

25 45.

0 . 2545XLOQ exponent
-

Mantisa
Character Representation
ASCII ~ Q
The code called ASCII (pronounced “AS-key”), which stands for
American Standard Code for Information Interchange, uses 7 bits
- - -
to represent each character in computer memory. The ASCII
-

representation has been adopted as a standard by the U.S.


government and is widely accepted. A unique integer number is
assigned to each character. This number called ASCII code of that
character is converted into binary for storing in memory. For
--
example, ASCII code of A is 65, its binary equivalent in 7-bit is
=

1000001. Since there are exactly 128 unique combinations of 7 bits,


-
-

this 7-bit code can represent only128 characters.


Another version is ASCII-8, also called extended ASCII, which uses
8 bits for each character, can represent 256 different characters.
-

For example, the letter A is represented by 01000001, B by


01000010 and so on. ASCII code is enough to represent all of the
standard keyboard characters.
EBCDIC -
It stands for Extended Binary Coded Decimal Interchange Code.
-
This is similar to ASCII and is an 8 bit code used in computers
manufactured by International Business Machine (IBM). It is
capable of encoding 256 characters. If ASCII coded data is to be
-

used in a computer which uses EBCDIC representation, it is


necessary to transform ASCII code to EBCDIC code. Similarly if
EBCDIC coded data is to be used in a ASCII computer, EBCDIC
code has to be transformed to ASCII .
ISCII -
ISCII stands for Indian Standard Code for Information Interchange
-
or Indian Script Code for Information Interchange. It is an encoding
-
scheme for representing various writing systems of India. ISCII
uses 8-bits for data representation. It was evolved by a
standardisation committee under the Department of Electronics
during 1986-88, and adopted by the Bureau of Indian Standards
-

(BIS). Nowadays ISCII has been replaced by Unicode.


-
-
Unicode
It aims to provide a standard character encoding scheme, which is universal
and efficient. It provides a unique number for every character, no matter what
the language and platform be. Unicode originally used 16 bits which can
represent up to 65,536 characters. It is maintained by a non-profit
organisation called the Unicode Consortium. Unicode can represent data in
-
almost all written languages of the world.
-
Boolean Algebra
Boolean Algebra a branch of mathematics that deals with operations on logical
values with binary variables. The Boolean variables are represented as binary
numbers to represent truths: 1 = true and 0 = false.

fa
E Boolean Variable Actors -

A variable which holds true/false value known as Boolean variable .(A,B,C etc)
-

-
Boolean Expression
Meaningfull combination of boolean operators(AND,OR,NOT) , Boolean
-
Variable/operand (X,Y,Z etc) and Boolean constant (0 or 1)
-
-
Boolean Operators and Logical Gates

-
=>>
1. AND
2. OR -
3. NOT -

LOGICAL GATE
-

A logical gate is a physical device that performs logical operations on one or


-
more logical inputs and produce a single logical output .

Note: A boolean Expression with ‘m’ operands(Variables) and ‘n’ operators


requires 2 raise to m Rows , m+n coloumns
-
Truth Table
-

>
A truth table is a representation of a boolean function or expression containing all
possible combinations of input values and their results in a tabular format .
S
1. AND OPERATOR and AND Gate
AND operator is a binary operator that operates on two variables and the
-

operation performed by AND operator is known as logical multiplication. The


-
symbol used for logical multiplication is dot (.) operator.
-

Logical Expression of AND

Y=A.B
Y AB=

Logical Gate of AND

diesrom AB
circuit >
- .

-
Truth Table -
O-Fale
-
--

1 = +au
= AB
.
-
>
-

T - -

>
>
-
7

> ->
>
-

>
-
X
2. OR Operator and OR Gate 23 -

The OR operator is a binary operator that operates on two variables and the
- -
operation performed by OR operator is known as logical addition. The symbol
-
used for logical addition is plus (+) operator.
-

Logical Expression
D
O
Y=A+B

Logical Gate -

-
-

=>
(
Truth Table

S
false : O

T= 1
AB
=

- >
-

>
-
>
-

- -

- -
I
NOT Operator and NOT Gate -
The NOT operator is a unary operator that operates on one variable and the
--

operation performed by NOT operator is known as negation or complementation.


-

Logical Expression

0
Y=A’ =
Logical Gate

>
-

T
Truth Table of NOT

S
A
=

=>

=>
1
UNIVERSAL GATES

=
1. NAND
2. NOR
NAND GATE
NAND Gate is an AND Gate with its output inverted by NOT gate.

.B
A
- ---

O .
--
-
O

-- 7

0--7
D - - -
DOE
Or

NOR Gate
NOR Gate is an OR Gate with its output inverted by NOT gate .

A+B >IB
-

T > -

1 -
- -

-
1
- -

= -
DOE
CIRCUIT DESIGNING

(A.B) + B
- -
z

E
(X+Y’) . U’
-

T
-a
#
(V’.O) + (V.O’)
---

D: +
(op
-
(A’.B’) + (K’+P)
Find dual of

1. A+0=A
2. AB+C+DG=1
3. A0+B.1=C
De Morgan’s Theorems

S
(A.B)’ = A’+B’
-
-
mon
(A+B)’ = A’ . B’ -
-

(i) "the complement of product of Boolean variables is equal to sum of their


individual complements". -

=
(ii) "the complement of sum of Boolean variables is equal to product of their
-
individual complements" and
Proof of First Law

(X+Y)’ = X’.Y’

-
=>
-
Proof of second Law
Implementation of basic gates using NAND and NOR

1. NOT GATE USING NAND GATE


AND GATE USING NAND GATE
OR GATE USING NAND GATE
NOT GATE USING NOR GATE
OR GATE USING NOR GATE
AND GATE USING NOR GATE
THANK YOU
(x+ y))= (x -
y))

·
1 - 5 1) 23 ... 55

~
We
= ② ⑦
aGa + !

T
St
op
-
F
Data types and Operators
Fundamental Data types
man
-
-

~ - -

X - -

- - -

-
-
- - -
Variable 1000-
-
Variables are the names given to memory locations .
-N
D 25 -

- -
-
10001001 love 1003
A variable has three parts ; Wit
-
1. Variable Name : It is a symbolic name (identifier) given to the memory
- -
location through which the content of the location is referred to .
-
- -

2. Memory address : Every cell (or byte) in RAM will be assigned a unique
-
address to refer it. The address is also called the L-value of a variable.
- -
-
3. Content : The valuem stored in the location is called content of the
-

variable. This is also called the R-value of the variable .


- -
- A, B, < ->

AFB-I
Operators operands
+
> Opea
-
-

Operators are tokens constituted by predefined symbols that can trigger


computer to carry out operations. The participants of an operation are called
-

operands.
Based on number of operands required for the operation, operators are
-
classified into three; unary, binary and ternary.
---
I
Unary Operator -
A unary operator operates on a single operand .
Eg: ++increment , - - decrement -
--

Binary Operator -
Binary operators operate on two operands .
-
-

Eg: + , - , && , < ,>= ,.. Etc


-

Ternary Operator -
Ternary operator operates on three operands.
-
Eg: Conditional Operator (?:)
-
Based on the nature of the operation Operators can be classified
into

1. Arithmetic Operators -
-
2. Relational Operators
3. Logical Operators - -
4. Input/Output Operators
5. Assignment Operators -
Arithmetic Operators +, , /
-

An

E
- - -

-
- -
-
-

-
-
= -
-

-
2
Relational Operators
2
~ -Listen O
f
tor-1
-Less thamoresual to
= 0
< =
-
1235

-8885
-
-

than = Equal to
I-greater
Not Emalto
or equal to ! >
greater
,
furn
-

= -
Logical Operators

I
-
>
-
-
TT
-
-
- -

-
-FF
-

-
7 -

F
-
-
Input/Output Operators

Input Operator
get from or Extraction (>>)
--

Output Operator

Put to or insertion (<<) [


&
Expressions
An expression is composed of operators and operands.

Arithmetic expressions

-
Floating Point Expression


Relational Expression

&
Logical expression
FFFFF FuF
-----
- -
Types of Statements in C++

---
1. Declaration Statement

It’s Syntax is :
-

Datatype var1,var2, …..var n ;


-
----

int a, b c
,
,
float by
2. Assignment Statement

W a

2-
Variable = Value

Variable 1= Variable 2
ab
C
Variable = Expression a= b + (x7
3. Input Statement -

cinjadaty
-

4. Output Statement -

cant c dath
-
=
Structure of C++ Program

#include <headerfile>
using namespace identifier;
int main()
{
statements;
:
:
:
return 0;
}
Preprocessor Directive -
-

● Preprocessors are the compiler directive statements which give


instruction to the compiler to process the information provided before
- =
actual compilation starts.
-

● These lines always start with a # (hash) symbol.


-
● Eg: #include , #define, #undef, etc.
-
--

·
Header files -

Header files contain the information about functions, objects and predefined
derived data types and are available along- with compiler.
-

Eg: <iostream> , <cmath> , <cstring> , …etc


--

Concept of namespace

- >
Different identifiers are associated to a particular namespace. It is actually a
-
group name in which each item is unique in its name.
The main() function
-

The execution starts at main() and ends within main().


-
Variable initialisation

data_type variable = value;


OR
data_type variable(value);

Eg :
float val=0.12, b=5.234;
char k='A';
Type Modifiers
Important modifiers are signed, unsigned, long and short
-

-
Arithmetic assignment operators


first

&
int > Inta
Type conversion
,
-

&
1. Implicit Type Conversion - fou

● Implicit type conversion is performed by C++ compiler internally


-
● the conversion is always from lower type to higher, it is also known as
type promotion. ~
Sk =
-

Eg:
5 / 2 * 3 + 2.5 - --

The evaluation steps are as follows: -

Step 1:--
5 / 2 -> 2 (Integer division)
-
Step 2: 2 * 3 -> 6 (Integer multiplication)
-

Step 3: 6 + 2.5 -> 8.5 (Floating point addition, 6 is converted into 6.0)
-
Explicit type conversion (Type casting) 1
-

● The programmer explicitly casts a data to the desired type, it is


also known as explicit type conversion or type casting.

Eg: Intby ,

float
by
= Giraff G + (10)b
wate a cot program to find sun o
two numbers ? ---

Sath
costreams
# include
using
namespace
Stay
int maine
E
int S, 4,b
;
Cont < "Entor
two numbers
(ing) ab
:

S
&

Saty
cont "Sun
is
"L;

retrono
,

You might also like