|
-
Aug 18th, 2000, 01:28 AM
#1
Thread Starter
Member
As we all no binary is a system of counting using only 0's and 1's. But how does this work? Well imagine an odometer (distance thingy in your car) that after it reaches a max number on one wheel it flips the one next to it one position. The base of the counting system denotes the number of positions on each. We use base 10 (ie. DECimal, DEC meaing 10) and there are 10 possible positions for our odometer 0,1,2,3,4,5,6,7,8,9. To convert a number from its base to base ten:
1) take a number
2) multiply its by its value
3) then by its base to the power of its' distance from the decimal point (NB the number to the left of the decimal point is distance 0, the one to the right is -1)
4) add it to a running total
5) do with all numbers
EXAMPLE USING HEXADECIMAL
number = A03D.C
1) A
2) A = 10
3) Base = 16
distance = 3
10 * 16^3 = 40960
4) Runing Total = 40960
1) 0
2) 0 = 0
3) base = 16
distance = 2
0 * 16^2 = 0
4) RT = 40960 + 0 = 40960
1) 3
2) 3 = 3
3) distance = 1
3 * 16^1 = 48
4) RT = 40960 + 48 = 41008
1) D
2) D = 13
3) distance = 1
13 * 16^0 = 13
4) RT = 356128 + 208 = 41021
1) C
2) C = 12
3) distance = -1
12 * 16^-1 = 0.75
4) RT = 41021.75
Therefore A03D.C = 41021.75
(check it on your WinCalculator)
you can see that it is neater and shorter.
for other bases replace 26 with the appropriate base #.
Please respond if you found this helpful or want clarification.
Visual Basic 6 Professional Edition
Captain Pinko
also:
Turbo Pascal, Turing, QBasic
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|