Tuesday, November 13, 2018

Arithmetic For Computers(Number Systems and Operations)


Number System

There are many types of number system.For example Binary,Octal,Decimal and Hexadecimal number.

BINARY NUMBER

 System Number
Base
Possible Digits
Binary
2
0 1

-Consist only  0  and  1.

    4    3    2    1   0  -  -2   
  2    2   2    2   2  2   2
n  n  n  n  n .n  n

The Most Significant Bits and Least Significant Bits is depends on the size of binary

DECIMAL NUMBER

 System Number
Base
Possible Digits
Decimal
10
0 1 2 3 4 5 6 7 8 9

The positive and negative values are determined by their position weight structure:-
   5   4    3    2    1    0
10  10  10  10  10  10   positive
  2    1    0   -1   -2   -3
10  10  10  10  10  10   negative


HEXADECIMAL NUMBER


 System Number
Base
Possible Digits
Hexadecimal
16
0 1 2 3 4 5 6 7 8 9 A B C D E F

-The Composed number start from 0 until F
-The number is suitable to present in fours bit number.

Number System Conversion



Convert Binary to Decimal
100110112

    7   6   5    4   3  2   1  0
    2  2   2   2  2  2  2  2
=128  64  32  16  8  4  2  1

   128  64  32  16  8  4  2  1
X   1   0   0  1   1  0  1   1
 128+ 0 +  0 + 16 +8 + 0 + 2  +1

=15510

Convert Binary to Hexadecimal


Convert Hexadecimal to Binary



Convert Hexadecimal to Decimal

    3   2    1    0
 16  16  16  16
A  2  F  7
     0
 7 x16 = 7
   1
F=15x16 = 240
2
2x16  = 512
3
10x16 = 40960

7+240+512+40960 = 4171910


Convert Decimal to Binary
15610

Convert Decimal to Hexadecimal
4156
             Balance
4156/16 = 259 ,  12
259/16 =16   ,  3
16/16=1     ,  0
1/16=0      ,  1

=103C16
* IT IS C BECAUSE 12 IN BASE 16 IS C

Convert Binary Fraction to Decimal
0.10112
Before point convert as usual
    -1
1 x 2  =0.5
   -2
0 x 2  =0
    -3
1 x 2  =0.125
   -4
1 x 2  =0.0625

0.5+0+0.125+0.0625 = 0.687510


Convert Decimal Fraction to Binary
3.70312510
Before point convert as usual

Convert Hexadecimal Fraction to Decimal
E5.D416

E=14
5=5
D=13
4=4

     1     0     -1    -2
14x16 + 5x16 . 13x16 + 4x16

=224 + 5 . (0.8125) + (0.015625)

Convert Decimal Fraction to Hexadecimal
-Multiply fractional part with 16 until get fractional 0.
0.0312510

0.03125 x 16 = 0.5   0  *write from up to down
0.5 x 16    =8.0    8
0

=0.0810
2`S Complement Number
-2`s complement method of representing number is commonly used.
Microprocessor process both positive and negative number.

-Assume a microprocessor have 8 bits.

If the most significant bit(MSB) is 0,then the number is positive,
If the most significant bit(MSB) is 0,then the number is negative.
The others 7 bits are represent as magnitude numbers.
The first bit from right is a least significant bit(LSB)


HOW TO DO??????
Given number            10101
1st Complement divert it to  01010
2nd Complement add 1      01011   =01011
  


Negative Number Convertion
For example:-

A decimal number for -125 is represented by 2s complement number = 1000 0000.
LETS CONVERT!

STEP 1
Convert to 7-bits Binary and do the 1st complement
STEP 2
ADD +1 to the 1st complement.
STEP 3
Do the 8-bits 2`s complement number by adding 1 for ngeative and 0 for postive MSB

1st = 125 is 0111 1101
          =000 0010

      2nd = 000 0011

     3rd = 000 0011
     -125 = 1000 0011

NUMBER OPERATION

A binary number operation only in Addition,Subtraction,Multiplication and Dvision.


BINARY ADDTION

For example 011+ 001
BINARY SUBTRACTION
For example 101 - 011

BINARY MULTIPLICATION

For example 1010 x 11



BINARY DIVISION
For example  11011 / 11

HEXADECIMAL OPERATION

For example convert 6010 to hexadecimal

1610  x  A ,Must = <6010
1610   310 = 4810

So,6010 - 4810 = 1210
Then Convert 1210 to hexadecimal and it is “C”
BECAUSE A is 3 so the answer is “3C”

HEXADECIMAL ADDITION
For Example 2F816 + 3816

8+8 =16,16 is 10 in hexadecimal
F+3=12 +1 CARRY is 13
2=2+1 CARRY is 3

HEXADECIMAL SUBTRACTION

For example 8416 - 2A16

2A16 = 001010102
2`s complement of  2A10 = 11010110 = +D6


HEXADECIMAL MULTIPLICATION

For example 3D16  x  516

D x 5 =4116
3 x 5 =F16 + 416  =13116


HEXADECIMAL DIVISION
For example 50F / B9

1 comment:

  1. Prepare4Test Adobe 9A0-395 PDF is designed with the latest 9A0-395 exam material. All questions are planned and verified by Adobe certified experts.

    ReplyDelete