BEEE P Unit 6 CMPT

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

Unit 6

Numbers Definition

Numbers are used in various arithmetic values applicable to carry out various arithmetic
operations like addition, subtraction, multiplication, etc which are applicable in daily lives for
the purpose of calculation. The value of a number is determined by the digit, its place value
in the number, and the base of the number system. Numbers generally also known as
numerals are the mathematical values used for counting, measurements, labeling, and
measuring fundamental quantities.

What is a Number System?

A Number system or numeral system is defined as an elementary system to express


numbers and figures. It is the unique way of representing of numbers in arithmetic and
algebraic structure.

Thus, in simple words, the writing system for denoting numbers using digits or symbols in a
logical manner is defined as a Number system. The numeral system Represents a useful set
of numbers, reflects the arithmetic and algebraic structure of a number, and provides standard
representation.

In the decimal number system, digits from 0 to 9 can be used to form all the numbers. With
these digits, anyone can create infinite numbers. For example, 156,3907, 3456, 1298, 784859,
etc. Other than digits, we can use alphabets such as A, B, C, D, E, and F (in Hexadecimal
Number System) to represent different numbers.

Types of Number Systems

Based on the base value and the number of allowed digits, number systems are of many
types. The four common types of Number systems are:

• Decimal Number System


• Binary Number System
• Octal Number System
• Hexadecimal Number System

Decimal Number System

A number system with a base value of 10 is termed a Decimal number system. It uses 10
digits i.e. 0-9 for the creation of numbers. Here, each digit in the number is at a specific
place with a place value of a product of different powers of 10. Here, the place value is
termed from right to left as the first place value called units, second to the left as Tens, so
on Hundreds, Thousands, etc. Here, units have a place value of 100, tens have a place
value of 101, hundreds as 102, thousands as 103, and so on.

Binary Number System

A number System with a base value of 2 is termed a Binary number system. It uses 2 digits
i.e. 0 and 1 for the creation of numbers. The numbers formed using these two digits are
termed Binary Numbers. The binary number system is very useful in electronic devices and
computer systems because it can be easily performed using just two states ON and OFF i.e. 0
and 1.

Decimal Numbers 0-9 are represented in binary as 0, 1, 10, 11, 100, 101, 110, 111, 1000, and
1001

For example, 14 can be written as 1110, 19 can be written as 10011, and 50 can be written as
110010.

Hexadecimal Number System

A number System with a base value of 16 is known as Hexadecimal Number System. It uses
16 digits for the creation of its numbers. Digits from 0-9 are taken like the digits in the
decimal number system but the digits from 10-15 are represented as A-F i.e. 10 is represented
as A, 11 as B, 12 as C, 13 as D, 14 as E, and 15 as F. Hexadecimal Numbers are useful for
handling memory address locations.

Roman Number System

The Roman numeral system is an ancient numerical system that was used in ancient Rome
and throughout the Roman Empire. It is based on a combination of letters from the Latin
alphabet to represent numbers. Here are the basic symbols used in the Roman numeral system
along with their corresponding values:

What is a Half-Adder?

A combinational logic circuit which is designed to add two binary digits is called as a half
adder. The half adder provides the output along with a carry value (if any). The half adder
circuit is designed by connecting an EX-OR gate and one AND gate. It has two input
terminals and two output terminals for sum and carry

From the logic circuit diagram of half adder, it is clear that A and B are the two input bits, S
is the output sum, and C is the output carry bit.
In the case of a half adder, the output of the EX-OR gate is the sum of two bits and the output
of the AND gate is the carry. Although, the carry obtained in one addition will not be
forwarded in the next addition because of this it is known as half adder.

Operation of Half Adder

Half adder adds two binary digits according to the rules of binary addition. These rules are as
follows −

0+0=0
0+1=1
1+0=1
1 + 1 = 10 (Sum = 0 & Carry = 1)

According to these rules of binary addition, we can see that the first three operations produce
a sum whose length is one digit, whereas in the case of last operation (1 and 1), the sum
consists of two digits. Here, the MSB (most significant bit) of this result is called a carry
(which is 1) and the LSB (least significant bit) is called the sum (which is 0).

Truth Table of Half Adder

Truth table is one that gives the relationship between inputs and outputs of a logic circuit and
explains the operation of the circuit. The following is the truth table of the half-adder −
What is a Full Adder?

A combinational logic circuit that can add two binary digits (bits) and a carry bit, and
produces a sum bit and a carry bit as output is known as a full-adder.

In other words, a combinational circuit which is designed to add three binary digits and
produces two outputs (sum and carry) is known as a full adder. Thus, a full adder circuit adds
three binary digits, where two are the inputs and one is the carry forwarded from the previous
addition.

Hence, the circuit of the full adder consists of one EX-OR gate, three AND gates and one OR
gate, which are connected together as shown in the full adder circuit in Figure

Operation of Full Adder

Full adder takes three inputs namely A, B, and Cin. Where, A and B are the two binary digits,
and Cin is the carry bit from the previous stage of binary addition. The sum output of the full
adder is obtained by XORing the bits A, B, and Cin. While the carry output bit (Cout) is
obtained using AND and OR operations.

Truth Table of Full Adder


Truth table is one that indicates the relationship between input and output variables of a logic
circuit and explains the operation of the logic circuit. The following is the truth table of the
full-adder circuit

BCD or Binary Coded Decimal

Binary Coded Decimal, or BCD, is another process for converting decimal numbers into
their binary equivalents

• It is a form of binary encoding where each digit in a decimal number is represented in


the form of bits.
• This encoding can be done in either 4-bit or 8-bit (usually 4-bit is preferred).
• It is a fast and efficient system that converts the decimal numbers into binary numbers
as compared to the existing binary system.
• These are generally used in digital displays where is the manipulation of data is quite
a task.
• Thus BCD plays an important role here because the manipulation is done treating
each digit as a separate single sub-circuit.

The BCD equivalent of a decimal number is written by replacing each decimal digit in the
integer and fractional parts with its four bit binary equivalent.the BCD code is more precisely
known as 8421 BCD code , with 8,4,2 and 1 representing the weights of different bits in the
four-bit groups, Starting from MSB and proceeding towards LSB. This feature makes it a
weighted code , which means that each bit in the four bit group representing a given decimal
digit has an assigned weight.
Excess-3 Code

The excess-3 code is also treated as XS-3 code. The excess-3 code is a non-weighted and
self-complementary BCD code used to represent the decimal numbers. This code has a biased
representation. This code plays an important role in arithmetic operations because it resolves
deficiencies encountered when we use the 8421 BCD code for adding two decimal digits
whose sum is greater than 9. The Excess-3 code uses a special type of algorithm, which
differs from the binary positional number system or normal non-biased BCD.

We can easily get an excess-3 code of a decimal number by simply adding 3 to each decimal
digit. And then we write the 4-bit binary number for each digit of the decimal number. We
can find the excess-3 code of the given binary number by using the following steps:

1. We find the decimal number of the given binary number.


2. Then we add 3 in each digit of the decimal number.
3. Now, we find the binary code of each digit of the newly generated decimal number.

We can also add 0011 in each 4-bit BCD code of the decimal number for getting excess-3
code.
Advantages of Excess-3 Codes

These are following advantages of Excess-3 codes,

• These are unweighted binary decimal codes.


• These are self-complementary codes.
• These use biased representation.
• The codes 0000 and 1111 are not used for any digit which is an advantage for memory
organization as these codes can cause fault in transmission line.
• It has no limitation, and it considerably simplifies arithmetic operations.
• It is particularly significant for arithmetic operations as it overcomes shortcoming
encountered while using 8421 BCD code to add two decimal digits whose sum
exceeds 9.

Gray Code
The Gray Code is a sequence of binary number systems, which is also known as reflected
binary code. The reason for calling this code as reflected binary code is the first N/2 values
compared with those of the last N/2 values in reverse order. In this code, two consecutive
values are differed by one bit of binary digits. Gray codes are used in the general sequence of
hardware-generated binary numbers. These numbers cause ambiguities or errors when the
transition from one number to its successive is done. This code simply solves this problem by
changing only one bit when the transition is between numbers is done.

The gray code is a very light weighted code because it doesn't depend on the value of the
digit specified by the position. This code is also called a cyclic variable code as the transition
of one value to its successive value carries a change of one bit only.
The reflected binary code or Gray code is an ordering of the binary numeral system such that
two successive values differ in only one bit (binary digit). Gray codes are very useful in the
normal sequence of binary numbers generated by the hardware that may cause an error or
ambiguity during the transition from one number to the next. So, the Gray code can eliminate
this problem easily since only one bit changes its value during any transition between two
numbers.

Gray code is not weighted that means it does not depends on positional value of digit. This
cyclic variable code that means every transition from one value to the next value involves
only one bit change.

Gray code also known as reflected binary code, because the first (n/2) values compare with
those of the last (n/2) values, but in reverse order.

How to generate Gray code?

The prefix and reflect method are recursively used to generate the Gray code of a number.
For generating gray code:

1. We find the number of bits required to represent a number.


2. Next, we find the code for 0, i.e., 0000, which is the same as binary.
3. Now, we take the previous code, i.e., 0000, and change the most significant bit of it.
4. We perform this process reclusively until all the codes are not uniquely identified.
5. If by changing the most significant bit, we find the same code obtained previously, then the
second most significant bit will be changed, and so on.
What is Hamming code?
Hamming code is an error correction system that can detect and correct errors when data is
stored or transmitted. It requires adding additional parity bits with the data. It is commonly
used in error correction code (ECC) RAM. It's named after its inventor, Richard W.
Hamming.

Whenever data is transmitted or stored, it's possible that the data may become corrupted. This
can take the form of bit flips, where a binary 1 becomes a 0 or vice versa. Error correcting
codes seek to find when an error is introduced into some data. This is done by adding parity
bits, or redundant information, to the data.

If enough parity data is added, it enables forward error correction (FEC), where errors can be
automatically fixed when read back. FEC can increase the data transmission rate for noisy
channels by reducing the amount of necessary retransmits.

Hamming code uses a block parity mechanism. The data is divided into blocks, and parity is
added to the block. Hamming code can correct single-bit errors and detect the presence of
two-bit errors in a data block.

The amount of parity data added to Hamming code is given by the formula 2p ≥ d + p + 1,
where p is the number of parity bits and d is the number of data bits. For example, if you
wanted to transmit 7 data bits, the formula would be 24 ≥ 7 + 4 + 1, so 4 parity bits are
required.

The type of error correcting is given as the name of the algorithm, the total number of bits in
the block and then the number of effective data bits. Therefore, Hamming encoding with 4
data bits and 3 parity bits for a total of 7 total bits is given as Hamming(7,4).

Boolean Algebraic Properties


Another type of mathematical identity, called a “property” or a “law,” describes how
differing variables relate to each other in a system of numbers.

The Commutative Property


One of these properties is known as the commutative property, and it applies equally to
addition and multiplication.

In essence, the commutative property tells us we can reverse the order of variables that are
either added together or multiplied together without changing the truth of the expression:
The Associative Property
Along with the commutative properties of addition and multiplication, we have the
associative property, again applying equally well to addition and multiplication.

This property tells us we can associate groups of added or multiplied variables together with
parentheses without altering the truth of the equations.
The Distributive Property
Lastly, we have the distributive property, illustrating how to expand a Boolean expression
formed by the product of a sum, and in reverse shows us how terms may be factored out of
Boolean sums-of-products:

To summarize, here are the three basic properties: commutative, associative, and distributive.
Basic Logic Gates
Logic gates are an important concept if you are studying electronics. These are important
digital devices that are mainly based on the Boolean function. Logic gates are used to carry
out logical operations on single or multiple binary inputs and give one binary output. In
simple terms, logic gates are the electronic circuits in a digital system

Types of Basic Logic Gates


There are several basic logic gates used in performing operations in digital systems. The
common ones are

• OR Gate
• AND Gate
• NOT Gate
• XOR Gate

Additionally, these gates can also be found in a combination of one or two. Therefore, we get
other gates, such as NAND Gate, NOR Gate, EXOR Gate and EXNOR Gate.

OR Gate

In an OR gate, the output of an OR gate attains state 1 if one or more inputs attain state 1.

The Boolean expression of the OR gate is Y = A + B, read as Y equals A ‘OR’ B.

The truth table of a two-input OR basic gate is given as


A B Y

0 0 0

0 1 1

1 0 1

1 1 1

AND Gate

In the AND gate, the output of an AND gate attains state 1 if and only if all the inputs are in
state 1.

The Boolean expression of AND gate is Y = A.B

The truth table of a two-input AND basic gate is given as

A B Y

0 0 0

0 1 0

1 0 0

1 1 1
NOT Gate

In a NOT gate, the output of a NOT gate attains state 1 if and only if the input does not attain
state 1.

The Boolean expression is

It is read as Y equals NOT A.

Y=𝑨

The truth table of NOT gate is as follows

A Y
0 1
1 0

When connected in various combinations, the three gates (OR, AND and NOT) give us basic logic
gates, such as NAND and NOR gates, which are the universal building blocks of digital circuits.

NAND Gate

This basic logic gate is the combination of AND and NOT gates.
The Boolean expression of the NAND gate is

The truth table of a NAND gate is given as

Y = 𝑨. 𝑩

A B Y
0 0 1
0 1 1
1 0 1
1 1 0
NOR Gate

This gate is the combination of OR and NOT gates.

The Boolean expression of the NOR gate is Y=𝑨 + 𝑩

The truth table of a NOR gate is as follows

A B Y
0 0 1
0 1 0
1 0 0
1 1 0

Exclusive-OR gate (XOR Gate)

In an XOR gate, the output of a two-input XOR gate attains state 1 if one adds only input and
attains state 1.
The Boolean expression of the XOR gate is Y=A.𝑩 + 𝑨.B

or

The truth table of an XOR gate is


A B Y
0 0 0
0 1 1
1 0 1
1 1 0

Exclusive-NOR Gate (XNOR Gate)

In the XNOR gate, the output is in state 1 when both inputs are the same, that is, both 0 or
both 1.

The Boolean expression of the XNOR gate

The truth table of an XNOR gate is given below


A B Y
0 0 1
0 1 0
1 0 0
1 1 1

You might also like