Sunday, 21 October 2012

1 ) Arithmetic for Computers (Number Systems and Operations)


1.1  Number system
           
       1.1.1    Basic Types Of Number System

The collection of unique digits that a computer can represent is one component of its number system. Most modern computers use the binary number system, which has only two digits, 0 and 1. The binary system is chosen because a computer must be able to represent each digit in some unique manner.
               
           There are many types number system. Here we only focus on the decimal, hexadecimal and    
      binary number.
             

     1.1.2 Number system base

Most of the numbering system will have a base. Refer the table below :-
System
Base
Possible Digits
Binary
2
0 1
Octal
8
0 1 2 3 4 5 6 7
Decimal
10
0 1 2 3 4 5 6 7 8 9
Hexadecimal
16
0 1 2 3 4 5 6 7 8 9  A B C D E F
   

             BINARY NUMBER
·         Base of 2
·         The system has two digits : 0 and 1
·         The weight of each position is a power of two
For example:
       
·         The least significant bit (LSB) and most significant bit (MSB) is depend on the size of binary number.



DECIMAL NUMBER

·         Base of 10
·         The radix point separate digit positions whose weights are positive and negative powers.

For example :
  •                …. 105, 104, 103, 102, 101, 100     [positive value] 
  •          ….102, 101, 100, 10-1, 10-2, 10-3 [negative value]


  
                  HEXADECIMALNUMBER

·         Base of 16
·         Start from 0 until F
·         Suitable to present in fours bit number


DECIMAL
BINARY
HEXADECIMAL
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
0000
0001
0010
0011
0100
0101
0110
0111
1000
1001
1010
1011
1100
1101
1110
1111
0
1
2
3
4
5
6
7
8
9
A
B
C
D
E
F
   
            

      










                




                1.1.3 Floating point numbers

·         Representation for non-integral numbers.
·         It is also useful to represent both very large and very small numbers.
·         Like scientific notation
~ 1234.56  [ 0.123456 x 104]
~0.000000123456789  [0.1234567 x 10-6]

1.1.4 IEEE standard for Floating point standard

·         Define by IEEE standard
·         Two representation
  1.          Single precision (32-bit) 
  2.      Double precision (64-bit)



     Single-precision range
  •      Exponents 00000000 and 11111111 reserved
    Double-precision range
  •        Exponents 0000…00 and 1111…11 reserved


                1.1.5 FD adder hardware

  •        Much more complex than integer adder
  •        Doing it in one clock would take too long 
                ~ much longer than integer operations
                      ~slower clock would penalize all instructions
  •          FP adder usually takes several cycles that can be pipe lined
                
                     Thank you for visit our blog :)

   
                                                                                                                  Written by: 
                                                                                          
                                                                                            NURFARAH ATHIRA BINTI MUHAMMAD TUAH

                                                        B031210253




    1.2 Computer Arithmetic

Most computers use complement arithmetic for integer representations. The reason for this is mostly to simplify the circuitry required to perform integer arithmetic operations.

Binary Number System
System Digits:  0 and 1
Bit (short for binary digit):  A single binary digit
LSB (least significant bit):  The rightmost bit
MSB (most significant bit):  The leftmost bit
Upper Byte (or nybble):  The right-hand byte (or nybble) of a pair
Lower Byte (or nybble):  The left-hand byte (or nybble) of a pair

Binary Equivalents
1 Nybble (or nibble)  =  4 bits
1 Byte  =  2 nybbles  =  8 bits
1 Kilobyte (KB)  =  1024 bytes
1 Megabyte (MB)  =  1024 kilobytes  =  1,048,576 bytes
1 Gigabyte (GB)  =  1024 megabytes  =  1,073,741,824 bytes

Binary Addition
  • 0 + 0 = 0
  • 0 + 1 = 1
  • 1 + 0 = 1
  • 1 + 1 = 0, and carry 1 to the next more significant bit
For example,
00011010 + 00001100 = 00100110
        
        1  1

carries
  0  0  0  1  1  0  1  0
   =   
26(base 10)
+ 0  0  0  0  1  1  0  0



   =   
12(base 10)
  0  0  1  0  0  1  1  0
   =   
38(base 10)

 
00010011 + 00111110 = 01010001
    
     1  1  1  1  1

carries
  0  0  0  1  0  0  1  1
   =   
19(base 10)
+ 0  0  1  1  1  1  1  0



   =   
62(base 10)
  0  1  0  1  0  0  0  1
   =   
81(base 10)
Note:  The rules of binary addition (without carries) are the same as the truths of the XOR gate.

Binary Subtraction
  • 0 - 0 = 0
  • 0 - 1 = 1, and borrow 1 from the next more significant bit
  • 1 - 0 = 1
  • 1 - 1 = 0
For example,
00100101 - 00010001 = 00010100
        
        0

borrows
  0  0  1 10  0  1  0  1
   =   
37(base 10)
- 0  0  0  1  0  0  0  1



   =   
17(base 10)
  0  0  0  1  0  1  0  0
   =   
20(base 10)

 
00110011 - 00010110 = 00011101
    
        0 10  1

borrows
  0  0  1  1  0 10  1  1
   =   
51(base 10)
- 0  0  0  1  0  1  1  0



   =   
22(base 10)
  0  0  0  1  1  1  0  1
   =   
29(base 10)
Binary Multiplication
Rules of Binary Multiplication
  • 0 x 0 = 0
  • 0 x 1 = 0
  • 1 x 0 = 0
  • 1 x 1 = 1, and no carry or borrow bits
For example,
00101001 × 00000110 = 11110110
        
0  0  1  0  1  0  0  1
   =   
41(base 10)
× 0  0  0  0  0  1  1  0



   =   
6(base 10)
0  0  0  0  0  0  0  0

0  0  1  0  1  0  0  1   

0  0  1  0  1  0  0  1      




0  0  1  1  1  1  0  1  1  0
   =   
246(base 10)

 
00010111 × 00000011 = 01000101
        
0  0  0  1  0  1  1  1
   =   
23(base 10)
× 0  0  0  0  0  0  1  1



   =   
3(base 10)
   1  1  1  1  1      

carries
0  0  0  1  0  1  1  1

0  0  0  1  0  1  1  1   




0  0  1  0  0  0  1  0  1
   =   
69(base 10)
Note:  The rules of binary multiplication are the same as the truths of the AND gate.
Another Method:  Binary multiplication is the same as repeated binary addition; add the multicand to itself the multiplier number of times.
For example,
00001000 × 00000011 = 00011000
        
           1

carries
  0  0  0  0  1  0  0  0
   =   
8(base 10)
  0  0  0  0  1  0  0  0
   =   
8(base 10)
+ 0  0  0  0  1  0  0  0



   =   
8(base 10)
  0  0  0  1  1  0  0  0
   =   
24(base 10)
Binary Division

Rules of Binary Division



  • Binary division is the repeated process of subtraction, just as in decimal division.


For example,

00101010 ÷ 00000110 = 00000111
        







 1 
 1 
 1 
   =   
7(base 10)



1  1  0 
)
 0 
 0 
 1 
1
 1 
 0 
 1 
 0 
   =   
42(base 10)




-  
 1 
 1 
 0 


   =   
6(base 10)









 1 




borrows



1 
 0 
1
 1 




-  
 1 
 1 
 0 










   
 1 
 1 
 0 




-  
 1 
 1 
 0 











 0 

 
10000111 ÷ 00000101 = 00011011
        





 1 
 1 
 0 
 1 
 1 
   =   
27(base 10)



1  0  1 
)
 1 
 0 
 0 
1
 0 
 1 
 1 
 1 
   =   
135(base 10)


-  
 1 
 0 
 1 




   =   
5(base 10)






 1 
 1 
1




-  
 1 
 0 
 1 












 1 
 1 





-  

 0 











 1 
 1 
 1 




-  
 1 
 0 
 1 











 1 
 0 
 1 




-  
 1 
 0 
 1 











 0 
Thank You for visit our blog :)
WRITTEN BY   :  `ADILAH HANANI BINTI ABDUL HAMID
(B031210170)



No comments:

Post a Comment