Monday, June 6, 2011

Binary To Decimal Conversions

Binary To Decimal Conversions

Binary number composed of 2 digits ie 0 and 1. In terms of computer programming, the binary number has a significant role because of all the binary code will be represented in binary form. For example, A has the code decimal number 65 in iplementasi the engine will be translated into the binary number 01000001. Code composed of a series of 0 and 1 would be difficult to understand. For that sometimes we change the binary code into decimal.
Suppose there is a binary code 01000001 then each digit can be represented in decimal as follows:
128 64 32 16 8 4 2 1

0 1 0 0 0 0 0 1

Any number 1 so we add the decimal representation is obtained:
64 + 1 = 65

Representations were obtained through the formula as follows:
1 X 2 ^ 0 = 1
1 X 2 ^ 1 = 2
1 X 2 ^ 2 = 4
1 X 2 ^ 3 = 8
1 X 2 ^ 4 = 16
1 X 2 ^ 5 = 32
1 X 2 ^ 6 = 64
1 X 2 ^ 7 = 128

Algorithm
0.Mulai
1.Tentukan binary, Bin
Bil long 2.Tentukan eg N
3.Tentukan Result = 0
4. Repeat I = 0 To N-1 Step 1
Result = Result + Num (I) * 2 ^ I
5. Repeat I
6. Print Results
7. Completed

Implementation
Private Sub Form_Activate ()
Dim I, N, Result As Byte
Bin = "01000001"
N = Len (Bin)
Result = 0
For I = 0 To N-1 Step 1
Result = Result + Num (I) * 2 ^ I
Next I
Print Bin; "is:"; Results
End Sub

No comments:

Post a Comment

 
THANK YOU FOR VISITING