Re: Binary number digits <- > Decimal number digits



On Dec 9, 1:52 pm, hagman <goo...@xxxxxxxxxxxxx> wrote:
On 9 Dez., 18:28, "mensana...@xxxxxxxxxxx" <mensana...@xxxxxxx> 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?

3.0102999566398119521373889472449 rounds to 4
giving you the correct answer: 10 bits makes
4 decimal digits.

Yep, and incidently 1024 indeed *has* 4 decimal digits.
But it also need 11 bits. Anyway, the biggest 10-bit number is 1023
and
is a 4-digit numerb, too.
Now, how many decimal digits will you get with 10,000 instead of 10
bits?

3010.2999566398119521373889472449

Does rounding play a big role here?

Sure, it rounds to 3011 (when done properly).

m = 2**10000 - 1
gmpy.numdigits(m,10)
3011

What is the bit-per-digit ratio for those big numbers?

Same as it is for small numbers.


hagman

.



Relevant Pages

  • Re: How to get decimal form of largest known prime?
    ... but I learned from it much about Python syntax. ... here code of a bigDecReprOfInt class as a kind of module and ... i.e. 4096 and not as I would expect it 80 decimal digits long ... # and strconversion for very large integers i. ...
    (comp.lang.python)
  • Re: Any progress yet? (was Re: Fast pi program?)
    ... conversion to base 26, ... Base 2^32 would /reduce/ the number of digits by a factor of about 1.7 ... numbers approximated with floating point is even worse.), the "pyramid ... it does cancel the performance gain if there was any. ...
    (comp.programming)
  • Re: Any progress yet? (was Re: Fast pi program?)
    ... conversion to base 26, ... you need to compute 2x the digits then convert to 26 (since the ... If you pack 4 elements and you use 8 primes ... numbers approximated with floating point is even worse.), the "pyramid ...
    (comp.programming)
  • Re: %x question
    ... %x is a conversion specifier that makes any of the printf ... the letters abcdef are used for x conversion and the letters ... fewer digits, it is expanded with leading zeros. ... The result of converting a zero value with a precision of zero is ...
    (comp.lang.c)
  • Re: Singles to Doubles
    ... I'm guessing that VB calculates its Singles and Doubles using some kind of power series expansion... ... Now, to continue my guessing, I think 15 digits were calculated for the Single and stored; but, because VB knows it is a Single, it only reports 6 of 7 digits when asked. ... Now, for the CStr conversion, I think VB is grabbing only the 6 or 7 digits it would normally use for display. ...
    (microsoft.public.vb.general.discussion)

Quantcast