|


Large-Number Binary ConversionDate: 01/25/2001 at 12:57:45 From: Lee Godden Subject: Binary conversion How do you convert very large binary numbers like 2^50 to base 10?
Date: 01/25/2001 at 16:56:25
From: Doctor Greenie
Subject: Re: Binary conversion
Hi, Lee -
For the specific example you show, the conversion is simple - just
multiply 2 times itself 50 times. Of course, whether you are using a
calculator, or a computer, or pencil and paper, you need to be able to
handle a number of about 16 digits.
However, I don't think you were asking about the particular example.
I think you were asking for the general method.
There are two basic methods for converting whole numbers from binary
(or any other base) to base 10. Here are the two methods, used to
convert the binary number 11001 to base 10:
(1) "Place Value" method...
From right to left, the place values in binary are 1, 2, 4, 8, 16, 32,
...; for the given number, the value (found by combining the value
each digit with the place value for that digit) is 25:
1 * 16 = 16
1 * 8 = 8
0 * 4 = 0
0 * 2 = 0
+ 1 * 1 = 1
-------------
= 25
(2) Alternate method
Start with the leftmost digit; repeatedly multiply by 2 and add the
next digit until all the digits have been used. The process is shown
in detail below, to demonstrate how this method produces the correct
results:
first digit (1): 1 (decimal equivalent of binary "1")
double: 2 (decimal equivalent of binary "10")
add next digit (1): 3 (decimal equivalent of binary "11")
double: 6 (decimal equivalent of binary "110")
add next digit (0): 6 (decimal equivalent of binary "110")
double: 12 (decimal equivalent of binary "1100")
add next digit (0): 12 (decimal equivalent of binary "1100")
double: 24 (decimal equivalent of binary "11000")
add last digit (1): 25 (decimal equivalent of binary "11001")
With this method, when you start with the first binary digit and
double and add the next binary digit, you get the decimal equivalent
of the leftmost two binary digits. Then when you double that and add
the third binary digit, you get the decimal equivalent of the leftmost
three binary digits. Continuing the process until all binary digits
have been used, you have the decimal equivalent of the entire binary
string.
The first method rapidly becomes unmanageable with large numbers of
binary digits (with a 50-digit binary number, you would have to
calculate the powers of 2 up to 2^49...). So for conversion from
binary to decimal for numbers with a large number of digits, the
alternate method is much easier to use.
The second method is also much easier to program, whether into a hand
calculation on a calculator or into a program for a computer. The
algorithm is quite simple:
start with first digit;
loop while more digits
double
add next digit
end loop;
In case you were confused by anything in the preceding explanation of
the two methods, here is a demonstration of the two methods, used to
"convert" the decimal number 12345 to base 10 ("convert" in quotation
marks, because there is no conversion to be performed; however, I
think this demonstration helps show the difference between the two
methods).
(1) "convert" decimal "12345" to base 10 using place value:
1 * 10000 = 10000
2 * 1000 = 2000
3 * 100 = 300
4 * 10 = 40
+ 5 * 1 = 5
-------------------
= 12345
(2) "convert" decimal value "12345" to base 10 by alternate method
first digit (1): 1 (base 10 equivalent of decimal "1")
times 10: 10 (base 10 equivalent of decimal "10")
add next digit (2): 12 (base 10 equivalent of decimal "12")
times 10: 120 (base 10 equivalent of decimal "120")
add next digit (3): 123 (base 10 equivalent of decimal "123")
times 10: 1230 (base 10 equivalent of decimal "1230")
add next digit (4): 1234 (base 10 equivalent of decimal "1234")
times 10: 12340 (base 10 equivalent of decimal "12340")
add last digit (5): 12345 (base 10 equivalent of decimal "12345")
- Doctor Greenie, The Math Forum
http://mathforum.org/dr.math/
|
Search the Dr. Math Library: |
[Privacy Policy] [Terms of Use]


Ask Dr. MathTM
© 1994-2010 The Math Forum
http://mathforum.org/dr.math/