1. NUMBER SYSTEM.pptx Computer Applications in Pharmacy

VedikaNarvekar1 3,617 views 35 slides Mar 12, 2024
Slide 1
Slide 1 of 35
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27
Slide 28
28
Slide 29
29
Slide 30
30
Slide 31
31
Slide 32
32
Slide 33
33
Slide 34
34
Slide 35
35

About This Presentation

B.Pharm SEM 2 Binary number system, Decimal number system, Octal
number system, Hexadecimal number systems, conversion decimal to
binary, binary to decimal, octal to binary etc, binary addition, binary
subtraction – One’s complement ,Two’s complement method, binary
multiplication, binary divis...


Slide Content

NUMBER SYSTEM

What is number system? Any system of naming or representing numbers as decimal system or binary system.

BINARY NUMBER SYSTEM Binary number refers to a term in which a number is expressed using two different symbols, i.e. 0 and 1. This system is used by all modern computers as well as computer based devices. Each digit in binary system is known as bit . b inary dig its = bits

Why do computers use binary system? Processor of each computer is made up of billions of transistors which include a switch that is activated by electronic signals. Digits used in binary system are 0 and 1 0 reflects ON 1 reflects OFF states of a transistor. Hence all types of software, music, videos, programs, documents are stored in binary language. Computers only understand base 2, i.e 0 (OFF) and 1 ( ON) Every piece of data passed through any part of the computer is done by using base 2 (binary) For an n- digit number, the value of a digit depends on its position.

Example: 10101 =base is 2 So, it will be calculated as 10101 b where b is 2 1x2 4 + 0x2 3 + 1x2 2 + 0x2 1 + 1x2 16+0+4+0+1 = 21

100011= base is 2 So, it will be calculated as 100011 b where b is 2 1x2 5 + 0x2 4 + 0x2 3 0x2 2 + 1x2 1 + 1x2 32+0+0+0+2+1 =35 Binary numbers are written as

Decimal number system Decimal number system composes of 10 digits namely 0,1,2,3,4,5,6,7,8 and 9 with base 10. It uses a dot (.) i.e. decimal point to denote fractions. In this system, position of every digit is important as 1 st position shows units place, 2 nd of the left being Tens place and next as Hundreds and so on.

Every digit positioned to the left of decimal point is 10 times bigger and every digit positioned to the right of decimal point is 10 times smaller .

Example In decimal system 2538 10 is written as 2538 10 = 2x10 3 + 5x10 2 + 3x10 1 + 8x10 = 2000 + 500 + 30 + 8 = 2538 d All numbers are represented as combination of digits 0-9 Position 3 2 1 . -1 -2 -3 Position value 10 3 10 2 10 1 10 10 -1 10 -2 10 -3 Quantity 1000 100 10 1 1 01 001

Octal number system Octal number system requires 8 as a base and 8 digits ( 0,1,2,3,4,5,6 and 7)

Example: 27 8 =2x8 1 + 7x8 = 16+7 = 23

Hexadecimal number system Hexadecimal number system has 16 as base. It has 10 numeric digits 0,1,2,3,4,5,6,7,8,9 and alphabets from A to F.

Example: BC12 16 = 11x16 3 + 12x16 2 + 1x16 1 + 2x16 = 45056 + 3072 +16 + 2 = 48146 BA59 16 = 11x16 3 + 10x16 2 + 5x16 1 + 9x16 = 45056 + 2560 + 80 + 9 = 47705

Conversion of decimal to binary Divide each decimal number by 2 that will give remainder as 1 or 0. The remainder at the top is known as Least Significant Bit (LSB) and at the bottom is known as Most Significant Bit (MSB). MSB CAN NEVER BE ZERO!!

Example: Convert 294 10 into binary number. Divide the number by 2 i.e 147 and remainder (LSB) Again divide by 2 i.e 73 and remainder 1 Divide by 2 i.e 36 and remainder 1 Divide by 2 i.e 18 and remainder Divide by 2 i.e 9 and remainder Divide by 2 i.e 4 and remainder 1 Divide by 2 i.e 2 and remainder Divide by 2 i.e and remainder 1 (MSB) ANSWER: 10100110 2

Conversion of binary to decimal Determine positional value of each digit. Multiply the obtained positional value of base 2 by the binary digit. Example: Convert (100101) 2 to decimal number. 100101= 1x2 5 + 0x2 4 + 0x2 3 + 1x2 2 + 1x2 1 + 1x2 = 32+0+0+4+0+1 = 37 Therefore, (100101) 2 = (37) 10

Conversion of octal to decimal Determine the positional value of each digit. Example: (62) 8 = 6x8 1 + 2x8 = 48 +2 = 50

Conversion of decimal to octal To Convert the decimal number into octal, divide the decimal number by 8. Example: (637) 10 = ? Hence (637) 10 = (1175) 8 Step Operation Quotient Remainder 1 637/8 79 5 2 79/8 9 7 3 9/8 1 1 4 1/8 1

Conversion of octal to binary First convert each octal digit into 3 digit binary number Combine all the binary groups of 3 digits into single binary number.

Conversion hexadecimal to binary Example 1: Convert 9AF into binary number. Consider binary number for each digit. Binary number 9 means 1001 A means 1010 F means 1111 9AF= (100110101111) 2

Example 2: CE45=? C = 1100 E = 1110 4 = 0100 5 = 0101 CE45= 1100111001000101

Conversion of binary to hexadecimal Consider an example, 1110110 Make groups of four binary digits from right to left. 111 0110 Add preceding zero. 111 0110 Now convert each number from each group to hexadecimal number. 0111 0110 7 6 Hence, (1110110) 2 = (76) 16

Binary addition Similar to normal method of addition. Following rules are to be considered for BINARY ADDITION. A+B Sum Carry 0+0 0+1 1 1+0 1 1+1 1

Example: 1. Add 10010 and 1001 it will be calculated as 10010 + 1001 11011 2. Add 00111 and 10101 0111 00111 +10101 11100

Consider an example: Suppose we have to add 0110 and 0111

Binary subtraction Binary subtraction is similar to normal subtraction. BINARY SUBTRACTION TABLE

Example: 1101- 011 =?

One’s complement method One’s compliment of a binary number is defined as the value obtained by inverting all the bits. i.e 0 will be written as 1 1 will be written as 0 Example: 10101 will be written as 01010-------- one’s complement of 10101. This is useful for obtaining two’s complement of a number.

Subtraction using one’s complement. A) 110101 – 100101 Solution: Find out 1’s complement of second number. 100101------- 011010 Add 1’s complement to 1 st number. 110101 + 011010 1 001111 (Add the carry) + 1 010000 -------- ANSWER! B) 101011 – 111001 111001----- 000110 101011 +000110 110001 No carry, then find out 1’s compliment of the obtained answer . 110001 ------ 001110-------- ANSWER!

Two’s complement This is used to represent negative integer values in binary. Example: Find out 2’s complement of 1001101. Step 1: Find out 1’s complement of original number. 1001101  0110010 Step 2: Add 1 to 1’s complemented value 0110010 + 1 0110011  two’s compliment of 1001101

Subtraction using two’s complement. Example 110110- 010110 Solution: Find out 2’s complement of second number. 010110  101001 1’s complement + 1 101010  2’s complement Add 2’s complement to 1 st number. 110110 + 101010 1 100000 If there’s a carry drop it. Answer will be 100000 If there’s no carry then find the 2’s complement of the final answer.

Binary multiplication The rules of binary multiplication are as follows. A X B Multiplication 0 x 0 0 x 1 1 x 0 1 x 1 1

Example:

Binary division Division in binary system is same as in decimal system. The quotient should be either 1 or 0 depending on the divisor. A/B 0/1 1/1 1

Example 1: 10010 / 11 Example 2: