Re: Binary number digits <- > Decimal number digits
- From: "mensanator@xxxxxxxxxxx" <mensanator@xxxxxxx>
- Date: Sun, 9 Dec 2007 20:35:07 -0800 (PST)
On Dec 9, 3:44 pm, Adam <n...@xxxxxxxx> wrote:
On Sun, 9 Dec 2007 09:28:13 -0800 (PST), mensana...@xxxxxxxxxxx wrote:
On Dec 9, 10:50?am, Jeremy Boden <jer...@xxxxxxxxxxxxxxx> wrote:
On Sun, 09 Dec 2007 16:58:11 +0100, Helmut Richter wrote:
On Sun, 9 Dec 2007, fc wrote:
For example, what calculus was made to arrive that a decimal number of
617 digits must have 2048 digits in binary? (Obviously, without make
the conversion of the decimal number 999999...99999 [617 9 numbers] to
binary) And: how to generalize for any decimal number of any length?
The number of digits of x in some base b is, not regarding rounding to
integers, the logarithm of x with respect to base b, which is ?log x /
log b (log to arbitrary base).
So the number of decimal digits of x is ?log 2 / log 10 = 0.30103 .
For a rough calculation, 2^10 = 1024,
So 10 bits is approximately 3 digits.
How come you didn't round up?
Rounding up is appropriate in this case -- for the value 1024.
It is not always appropriate -- for an arbitrary n-bit value.
But that wasn't asked.
The following is an incomplete question:
"How many decimal digits are available from an n-bit binary number?"
What was asked was how many bits are required
for an n-digit decimal number.
What does the questioner mean by "How many?"
Do they mean "at _most_ 'x' digits"? If so, we always round up.
It was _exactly_ 617 decimal digits, with each
digit a 9.
Or do they mean "at _least_ 'x' digits"? If so, we might round down.
Not applicable.
Let's take a closer look at a 10-bit integer.
1023 is an unsigned 10-bit integer in which all bits are set:
11 1111 1111 (binary) = 1023 (decimal) -- four decimal digits.
10 * log(2)/log(10) = 3.01
Rounding up may suggest that we can always get 4 decimal digits from a
10-bit integer when the highest-order bit is in use.
If you have 3.x gallons of water in a tank a
1 gallon bucket to transfer it with, you're going
to make 4 goes regardless of how small x is as long
as x>0.
But such is not the case.
Because you're doing it backwards?
512 is also an unsigned 10-bit integer -- it requires the use of the
highest order bit in a 10-bit integer, which is 2^9:
10 0000 0000 (binary) = 512 (decimal) -- three decimal digits.
The following are true statements:
1. We can get _at most_ 4 decimal digits from a 10-bit unsigned
integer.
2. We can get _at least_ 3 decimal digits from a 10-bit unsigned
integer when the highest-order bit is in use.
Whether we round the digit-conversion calculation up or down may
depend on:
1. What we're after when we ask "how many digits"?
2. The width of the binary representation -- which determines the
fractional part in the result of n * log 2 / log 10. It may be that
when this fractional part is "large enough", we round up for either
case.
On Sun, 9 Dec 2007 07:39:24 -0800 (PST), fc wrote:
And: how to generalize for any decimal number of any length?
Consider the following two 5-digit decimal numbers:
expression decimal number bits required
2^16 - 1 65,535 16
2^16 + 2^14 81,920 17
5 * log(10) / log(2) = 16.6
Round up or down comes into play again.
Nope. A 617 digit decimal display will _require_
a 2050-bit register if you plan to shown _every_
possible 617-digit decimal number.
There may be some 617-digit numbers (such as RSA
challenge) that can get away with fewer bits, but
the OP specifically said all 9's, so rounding
down doesn't enter into it.
Adam
--
Posted via a free Usenet account fromhttp://www.teranews.com- Hide quoted text -
- Show quoted text -
.
- Follow-Ups:
- References:
- Binary number digits <- > Decimal number digits
- From: fc
- Re: Binary number digits <- > Decimal number digits
- From: Helmut Richter
- Re: Binary number digits <- > Decimal number digits
- From: Jeremy Boden
- Re: Binary number digits <- > Decimal number digits
- From: mensanator@xxxxxxxxxxx
- Re: Binary number digits <- > Decimal number digits
- From: Adam
- Binary number digits <- > Decimal number digits
- Prev by Date: Re: Finding all paths between two vertices in a graph
- Next by Date: Re: Binary number digits <- > Decimal number digits
- Previous by thread: Re: Binary number digits <- > Decimal number digits
- Next by thread: Re: Binary number digits <- > Decimal number digits
- Index(es):
Relevant Pages
|
Loading