Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #163619

Re: ot: on a base being a power of another

From Bart <bc@freeuk.com>
Newsgroups comp.lang.c
Subject Re: ot: on a base being a power of another
Date 2021-11-23 19:57 +0000
Organization A noiseless patient Spider
Message-ID <snjh2d$h3m$1@dont-email.me> (permalink)
References <86mtlyh6vu.fsf@levado.to> <snbv5i$eqi$1@dont-email.me> <86v90ilnl7.fsf@levado.to>

Show all headers | View raw


On 23/11/2021 18:43, Meredith Montgomery wrote:
> James Kuyper <jameskuyper@alumni.caltech.edu> writes:

>> To make that more concrete, consider b=3, k=2, a[k] = {2, 1, 0, 0, 1, 2}
>> Carry out the calculations shown above for n=0, n=1, and n=2. Hopefully,
>> that exercise will make it clearer. This shows that 210012 base 3 == 705
>> base 9, because 7 base 9 == 21 base 3 and 5 base 9 == 12 base 3.
> 
> You really understood my request.  Thank you.
> 
> I'm having some difficulties carrying out the calculations.
> 
> I suppose when n=0 the group is 12, when n=1 the group is 00 and so on.
> 
> Using your example, I get
> 
>    210012_3 = a[5]*3^5 + a[3]*3^3 + a[1]*3^1
> 
> But I think a[5] is the fifth digit from right to left, starting at
> zero, so a[5] = 2, a[3] = 0, a[1] = 1, so I get
> 
>    210012_3 = 2*3^5 + 0*3^3 + 1*3^1
>             = 6*3^4 + 0*3^2 + 3
>             = 6*9^2 + 0*3^2 + 3
>             = 603_9,
> 
> unless I got confused with bases there.  I did multiply 2*3 and I wrote
> 6 as an answer --- I'm guess I'm working in base ten there.

210012 in base 3 is 572 decimal, which is 705 in base 9.

You can do the 210012 to base 10 conversion like this:

       5   4   3   2   1   0      Units column
     243  81  27   9   3   1      3**units column

       2   1   0   0   1   2

Sum 243*2 + 81*1 + 3*1 + 1*2 to get 572.

I still don't know what it is you're trying to do, but a direct 
conversion to base 9 can be done with:

      3      2     1       0        Units column
    729     81     9       1        9**units colun

      -      7     0       5
         2*3+1     -   1*3+2        The 2, 1, 1 ,2 digits from above

Back to comp.lang.c | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

ot: on a base being a power of another Meredith Montgomery <mmontgomery@levado.to> - 2021-11-20 18:08 -0300
  Re: ot: on a base being a power of another Ben Bacarisse <ben.usenet@bsb.me.uk> - 2021-11-20 22:22 +0000
  Re: ot: on a base being a power of another Bart <bc@freeuk.com> - 2021-11-20 22:27 +0000
  Re: ot: on a base being a power of another James Kuyper <jameskuyper@alumni.caltech.edu> - 2021-11-20 18:08 -0500
    Re: ot: on a base being a power of another Meredith Montgomery <mmontgomery@levado.to> - 2021-11-23 15:43 -0300
      Re: ot: on a base being a power of another Bart <bc@freeuk.com> - 2021-11-23 19:57 +0000
      Re: ot: on a base being a power of another "james...@alumni.caltech.edu" <jameskuyper@alumni.caltech.edu> - 2021-11-23 16:53 -0800
        Re: ot: on a base being a power of another Meredith Montgomery <mmontgomery@levado.to> - 2021-11-24 11:14 -0300
  Re: ot: on a base being a power of another Manfred <noname@add.invalid> - 2021-11-21 05:41 +0100

csiph-web