Re: Binary number digits <- > Decimal number digits
- From: Adam <no@xxxxxxxx>
- Date: Sun, 09 Dec 2007 16:44:00 -0500
On Sun, 9 Dec 2007 09:28:13 -0800 (PST), mensanator@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.
The following is an incomplete question:
"How many decimal digits are available from an n-bit binary number?"
What does the questioner mean by "How many?"
Do they mean "at _most_ 'x' digits"? If so, we always round up.
Or do they mean "at _least_ 'x' digits"? If so, we might round down.
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.
But such is not the case.
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.
Adam
--
Posted via a free Usenet account from http://www.teranews.com
.
- Follow-Ups:
- Re: Binary number digits <- > Decimal number digits
- From: mensanator@xxxxxxxxxxx
- Re: Binary number digits <- > Decimal number digits
- From: Gerard Schildberger
- Re: Binary number digits <- > Decimal number digits
- From: Adam
- Re: Binary number digits <- > Decimal number digits
- 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
- Binary number digits <- > Decimal number digits
- Prev by Date: Re: Factorising this...
- Next by Date: Re: Coverge or diverge
- Previous by thread: Re: Binary number digits <- > Decimal number digits
- Next by thread: Re: Binary number digits <- > Decimal number digits
- Index(es):
Relevant Pages
|