Arithmethic for computer

Introduction and concept

Every single data in a computer whether a numbers, words, of symbols are made up from numbers including the instruction to the computer which well known as machine language.

There are 3 types of number system in computer, that usually used by a programmer and  a compute which are binary,decimal, and hexadecimal. The following tables show the type of numbering system :-


Table 1.0 Numbering System

Binary Number :-

- Used only 2 digit which are made up  of 1 and 0 only.
- 1 byte consist of 8 bits. 
- Every digit in binary number is called as bit. Every single bit position has it's own weight and value. The least significant bit (LSB) and Most significant bit (MSB) is depends on the size of binary number.

Table 1.1 LSB and MSB

The LSB and MSB depends on their size of bit number.


Decimal Number :-

- The most common used for numbering system.
- Used 10 digit number which are 1,2,3......9.
- Operations that can be done in this system is addition, subtraction, multiplication and division.
- The positive and negative valued is determined by its position .
- The value of the bits is determined by value of its exponent.
   (e.g : 2^1 = 2 while 2^-1 = 0.5 )

Hexadecimal Number : -

- Hexadecimal number is widely used in programming and microcomputer operation.
 It uses sixteen distinct symbols, most often the symbols 09 to represent values zero to nine, and
    A, B, C, D, E, F  to represent value ten to 15.
- Weight for hexadecimal are derived from the  power of the number


Number  Conversion

  • Binary to Decimal
Steps : 

1) Multiply every bit with it weight value.
2) Add every sum of multiplication of bit with it weight value.

example : -
  ******************video********************


* Using dibble-dobble method *

This the first time we see this method but as we study and have a better understanding,this method is quite interesting. Have a try ! :)


steps : 

1) Copy the first bit.

2) Multiply with 2 , and  add with the next bit.
3)     ************** video********************
  • Binary to Hexadecimal

1st way : -

1 - If there are 8 bit number , divide it by 2 column,each fill with 4 bit number.
2 - Let 4 bit number held a a number of 8,4,2,and 1 underneath it.
3 - Convert the binary and add up the sum.
4 - Combine the 4 digit number left and right.

2nd way :-

1 - Convert the binary number into decimal number.
2 - Multiply the digit with its weight value.
3 - Add all the sum of multiplication
4 - Convert the decimal to hexadecimal
  •  Decimal to Binary
there are 2 ways of doing it :-

first way (integer)

1- Divide the number by 2.
2- Remainder of the division must be the digit.
3- Repeat step 1 till the divisor become 0.
4- Read the remainder from bottom to top.

2nd way (decimal)

1) Multiply decimal no with 2
2) If the answer is not 1.00,Then take the decimal point and multiply it with 2.
3) Repeat step 1-2 until the answer is 1.00.
4) Write the answer from top to bottom by taking the number before the decimal point.

  • Decimal to Hexadecimal

1) Divide the decimal number by 10.
2) Remainder of the division will be the answer.
3) Repeat the steps 1-2 till you get 0.
4) Read the answer from bottom to top.

  • Hexadecimal to Binary
1) Divide the bit by 4 bit per box
2) Let the 4 bit carry value 8,4,2,1 by 1 digit value.
3) Then add the sum of value from the table 
4) Write the answer.

  • Hexadecimal to Decimal
1st way

1) Convert hexadecimal number into binary number
2) Add the binary number.
3) Convert into decimal number.

2nd way

1) Multiply each digit with their weight value.
2)Add the sum of multiplication.


Complement Number

  • In arithmethic operations,positive and negative number number used binary number for a better understanding to the computer. The MSB will determine the binary number is positive and negative.
  • If the MSB bit is '0' , then the number is positive . Conversely if the MSB bit is 1, then the number is negative. The other 7 bit represent the magnitude number. The first bit from right is a least significant bit (LSB).

1's complement
2's complement


- Ways to determine the negative number by comparing the number in the 2's complement.
- On order to convert the number into 2's complement,we must do the 1's complement first.

ways to convert binary into 1's and 2's complement.

1) Reverse all the binary number in its 1's complement.
2) Add 1 at the last right number

** This method is used for negative number only.For 2's complement of positive number, we just convert it to binary number only. That's it. 






By, Nur Azalina Hamdan.







No comments:

Post a Comment