Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

Computer Basics and

Programming Fundamentals
Dr. Md. Sazzad Hossain 20th Aug 2023

Number System
A number system is a systematic way of representing and expressing numbers. Different number systems
use different symbols and rules to represent quantities. The most used number systems include:

Decimal Number System (Base 10): This is the number system we use in everyday life. It's based on
powers of 10, where each digit's position represents a power of 10. For example, the number 253 is
interpreted as (2 ×102) + (5 ×101) + (3 × 100).

Binary Number System (Base 2): The binary system is used extensively in digital electronics and
computing. It uses only two symbols, 0 and 1. Each digit's position represents a power of 2. For example,
the binary number 1011 is interpreted as (1 × 23) + (0 × 22) + (1 × 21) + (1 × 20), which is equivalent to 11 in
decimal.

Octal Number System (Base 8): Octal uses eight symbols, 0 to 7. Each digit's position represents a power
of 8. Octal is sometimes used in computing contexts where compact representation is important.

Hexadecimal Number System (Base 16): Hexadecimal uses sixteen symbols: 0-9 for the first ten digits
and A-F for the remaining six. Each digit's position represents a power of 16. Hexadecimal is often used in
computing for representing memory addresses, colors, and other values.

Binary Number System:

Binary is fundamental in digital systems because computers use electronic components that can be in one
of two states, often represented as 0 and 1. Here's how the binary system works:

1. Each digit in a binary number is called a bit (short for binary digit).
2. The rightmost bit is the least significant bit (LSB), and the leftmost bit is the most significant bit
(MSB).
3. Just like in the decimal system, the position of a bit indicates its value, but in binary, each position
represents a power of 2.
4. For example, the binary number 1101 can be interpreted as (1 × 23) + (1 × 22) + (0 × 21) + (1 × 20),
which equals 13 in decimal.

Binary is the foundation of all digital data in computers. Complex data structures, instructions, images,
videos, and everything else in the digital world are represented using sequences of binary numbers. It's the
language that computers understand and process at their core.
Binary Transformation
To transform a binary number to a decimal number:

(101011)2

1 × 25 + 0 × 24 +1 × 23 + 0 × 22 + 1 × 21 + 1 × 20

32 + 8 + 2 + 1

(43)10

To transform a binary number to an octal number:

(10011010)2

010 011 010

0+2+0 0+2+1 0+2+0

(232)8

To transform a binary number to a hexadecimal number:

(10111010010110)10

0010 1110 1001 0110

2 14 9 6

(2E96)16

Binary Addition and Subtraction


Addition:

100111010010101

+ 111010001010101

(1) 100001011101010

Here, 1 + 0 = 1, 0 + 0 = 0, 1 + 1 = 0 with 1 to carry and,1 + 1 + 1 = 1 with 1 to carry. Also, the 1 in the


bracket is carry bit.
Subtraction:

This process is different from the last. There is no logic to subtract binary bits. So, we need to use 2’s
compliment to change a number to negative.

11010111

- 10111001

Calculating the 2’s compliment of the second number:

10111001

1’s compliment 01000110

+1

2’s compliment 01000111

+ 11010111

Result (1) 00011110

Here (1) in the front of result is the carry bit.

Boolean Algebra
Boolean algebra helps simplify complex expressions, making them easier to understand and implement. It
follows specific rules like the distributive law, commutative law, and others, just like regular algebra.

Boolean algebra is essential in computer science, digital circuit design, programming, and many other
fields where logical decisions need to be made based on binary data (true/false, on/off). It provides a formal
framework to analyze and manipulate these binary relationships efficiently.

Some Boolean formulas:

1. A+0=A 7. A.A’=0
2. A+1=1 8. A ‘’ = A
3. A.0=0 9. A + AB = A
4. A.1=A 10. A+A‘B=A+B
5. A+A=A.A=A 11. (A+B)(A+C)=A+BC
6. A+A’=1 12. A ‘ . B ‘ = (A + B) ‘

Here A is an independent Boolean variable. Plus (+) is an OR operation, dot (.) is an AND operation and
backtick (‘) is a NOT operation.
Here is an example of using Boolean algebra:

ABC’ + ABC + A’BC

AB (C’ + C) + A’BC

AB . 1 + A’BC

B (A + A’C)

Logic Gates
Logic gates are fundamental building blocks of digital circuits and computer systems. They are electronic
devices that perform basic logical operations on one or more binary inputs to produce a binary output.
Logic gates are the foundation upon which complex digital systems are constructed. Each type of logic
gate represents a specific logical function. Here are the examples.
OR Gate:

An OR gate takes multiple inputs and returns TRUE (1) or FALSE (0) given any one of those inputs are TRUE.

X=A+B

Here is the truth table of an OR gate:

A B X
0 0 0
1 0 1
0 1 1
1 1 1

AND Gate:

An AND gate takes multiple inputs and returns TRUE (1) or FALSE (0) given both of those inputs are TRUE.

X=A.B
Here is the truth table of an AND gate:

A B X
0 0 0
1 0 0
0 1 0
1 1 1

NOT Gate

A NOT gate takes one input and returns the opposite as an output.

X = A’

Here is the truth table for a NOT gate:

A X
0 1
1 0

Those are the examples of the primary logic gates. There are others such as NAND Gate, NOR Gate, XOR
Gate and XNOR Gate.

Universal Gates
Universal logic gates are the gates that can be used to represent any other gates. Such as NAND gate and
NOR gate.

NOT gate using NAND gate:

X = (A . A)’

X = A’
OR gate using NAND gate:

X = (A’ . B’)’

X = (A + B)’’

X=A+B

Logic Gate Circuits


Here is an example of a logic gate circuit using a previous Boolean expression.

X = B (A + A’C)

You might also like