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


Groups > comp.lang.javascript > #27588

Re: Calculate/Interpolate size of y in x^y = z when you do know "number of digits z" and base x?

Newsgroups comp.lang.javascript
Date 2015-05-11 06:12 -0700
References <a82630ee-3383-4c55-8da3-4cb092bcc1ae@googlegroups.com> <f7e8df7f-843c-43e8-8c00-66a30ac810dc@googlegroups.com> <dd8b527d-a2f8-428d-9419-2b5d2017baab@googlegroups.com> <87oalr8e8a.fsf@bsb.me.uk>
Message-ID <1bf84118-cdf4-40de-8913-bc86abe4db65@googlegroups.com> (permalink)
Subject Re: Calculate/Interpolate size of y in x^y = z when you do know "number of digits z" and base x?
From jonas.thornvall@gmail.com

Show all headers | View raw


Den måndag 11 maj 2015 kl. 14:56:28 UTC+2 skrev Ben Bacarisse:
> jonas.thornvall@gmail.com writes:
> 
> > Den måndag 11 maj 2015 kl. 13:28:06 UTC+2 skrev jonas.t...@gmail.com:
> >> Den måndag 11 maj 2015 kl. 13:22:30 UTC+2 skrev jonas.t...@gmail.com:
> >> > If i have a very bignumber z in decimal, i know the number of
> >> > digits let us say 100 digits and base is x=64.
> >> > 
> >> > How can i interpolate, find a closeby y (where base is x). 
> >> > I do understand that i can add 1 to y until i reach the neighbourhood.
> >> > 
> >> > But is there any general rule to use to close in faster when you
> >> > do know x and the number of digits in z?
> >> 
> >> Sorry i was not clear i look for the closest integer of y bigger or smaller.
> >
> > But maybe assuming y is large like 1000 doing a search closing in by
> > setting min and max is faster, than doing the calculation using
> > logaritms?
> 
> It depends on how y is represented.  You say it is "in decimal".  If
> that means it's a string then you just find the . and remove any
> trailing digits.  This is so obvious that it can't be whay you mean.
> How is z stored in the program?
> 
> -- 
> Ben.

An example using a small integer we search 2188 and base is 3. 

So 2188=3^y   
y is an integer.

I think mathetmaticians use logarithms for this kind of problem, but i am not sure that is fastest approach. Maybe a search algorithm, or other approaches are faster when one know the number of digits?

In this case the seareched number would be y=7 since i search (min?) the smaller value, not y=8 (max?) the bigger value. 

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Calculate/Interpolate size of y in  x^y = z  when you do know "number of  digits z" and  base  x? jonas.thornvall@gmail.com - 2015-05-11 04:22 -0700
  Re: Calculate/Interpolate size of y in  x^y = z  when you do know "number of  digits z" and  base  x? jonas.thornvall@gmail.com - 2015-05-11 04:28 -0700
    Re: Calculate/Interpolate size of y in  x^y = z  when you do know "number of  digits z" and  base  x? jonas.thornvall@gmail.com - 2015-05-11 05:47 -0700
      Re: Calculate/Interpolate size of y in  x^y = z  when you do know "number of  digits z" and  base  x? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-05-11 13:56 +0100
        Re: Calculate/Interpolate size of y in  x^y = z  when you do know "number of  digits z" and  base  x? jonas.thornvall@gmail.com - 2015-05-11 06:12 -0700
          Re: Calculate/Interpolate size of y in  x^y = z  when you do know "number of  digits z" and  base  x? jonas.thornvall@gmail.com - 2015-05-11 06:19 -0700
          Re: Calculate/Interpolate size of y in  x^y = z  when you do know "number of  digits z" and  base  x? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-05-11 21:49 +0100
  Re: Calculate/Interpolate size of y in  x^y = z  when you do know "number of  digits z" and  base  x? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-11 15:19 +0200
    Re: Calculate/Interpolate size of y in  x^y = z  when you do know "number of  digits z" and  base  x? jonas.thornvall@gmail.com - 2015-05-11 06:25 -0700
    Re: Calculate/Interpolate size of y in  x^y = z  when you do know "number of  digits z" and  base  x? jonas.thornvall@gmail.com - 2015-05-11 06:30 -0700
      Re: Calculate/Interpolate size of y in  x^y = z  when you do know "number of  digits z" and  base  x? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-11 18:18 +0200
        Re: Calculate/Interpolate size of y in  x^y = z  when you do know "number of  digits z" and  base  x? jonas.thornvall@gmail.com - 2015-05-11 09:32 -0700
          Re: Calculate/Interpolate size of y in  x^y = z  when you do know "number of  digits z" and  base  x? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-11 19:45 +0200
            Re: Calculate/Interpolate size of y in  x^y = z  when you do know "number of  digits z" and  base  x? "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-05-11 22:58 +0200
              Re: Calculate/Interpolate size of y in  x^y = z  when you do know "number of  digits z" and  base  x? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-11 23:13 +0200

csiph-web