Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #29232
| Newsgroups | comp.lang.javascript |
|---|---|
| Date | 2016-01-11 07:56 -0800 |
| References | <86bb6f49-d74d-426d-bc2a-5b4cd7199bf4@googlegroups.com> <69c96cdd-1020-470c-b0b2-66e2898468bb@googlegroups.com> <87si24w8id.fsf@bsb.me.uk> <5693bf11$0$23861$e4fe514c@news.xs4all.nl> <87fuy4w27e.fsf@bsb.me.uk> |
| Message-ID | <58985c2c-1555-448d-9180-e513da33a0fc@googlegroups.com> (permalink) |
| Subject | Re: Improve speed calculations? |
| From | jonas.thornvall@gmail.com |
Den måndag 11 januari 2016 kl. 16:44:32 UTC+1 skrev Ben Bacarisse: > Silvio <silvio@internet.com> writes: > > > On 01/11/2016 02:28 PM, Ben Bacarisse wrote: > >> jonas.thornvall@gmail.com writes: > >> > >>> Den söndag 10 januari 2016 kl. 14:33:27 UTC+1 skrev jonas.t...@gmail.com: > >>>> <script language="Javascript"> > >> <snip code> > >>> http://jt.node365.se/BAUTABASE.html > >>> > >>> Using the biggest base possible adding "4503599627370495" encoding > >>> fibonacci in javascript without overflow. > >>> > >>> Also fixed ambiguity reading out the numbers in bases over ten by > >>> using separator for digitplaces. The add can not cause overflow but to > >>> get rid of base overflow would require some real deep thinking. > >>> > >>> The 100000th Fibonacci took 34 seconds i do not think i can get it > >>> much faster in javascript if your a wizard please prove me wrong. > >> > >> I have not tried your code, but I've just written a quick bignum add > >> function and I can get fib(100000) in about 3.5 seconds. If I have time > >> to unravel yours, I'll do a comparative test. Note that a language with > >> a good bignum type (Haskell, for example) will do it in less than 100th > >> of a second. > >> > >> Note that your 'challenge' makes it easy to optimise the code. For > >> example, using a power of 10 as the base makes the conversion for > >> printing very simple. > >> > > > > That is well neigh impossible if you used a 10-based decimal since > > Jonas uses a huge base and is convinced that using a larger base will > > make computations much faster. Your result would invalidate that > > claim... > > Using base 10 is quite slow (my code needs 23s for fib(100000) using > base 10), but I use a higher power of 10 as the base for speed whilst > keeping printing simple. With higher powers, you do get faster results > (up to a limit, of course!). > > -- > Ben. What timing for the 1 million th Ben?
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Improve speed calculations? jonas.thornvall@gmail.com - 2016-01-10 05:33 -0800
Re: Improve speed calculations? jonas.thornvall@gmail.com - 2016-01-11 03:19 -0800
Re: Improve speed calculations? jonas.thornvall@gmail.com - 2016-01-11 04:41 -0800
Re: Improve speed calculations? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-01-11 13:28 +0000
Re: Improve speed calculations? Silvio <silvio@internet.com> - 2016-01-11 15:41 +0100
Re: Improve speed calculations? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-01-11 15:44 +0000
Re: Improve speed calculations? jonas.thornvall@gmail.com - 2016-01-11 07:53 -0800
Re: Improve speed calculations? jonas.thornvall@gmail.com - 2016-01-11 07:56 -0800
Re: Improve speed calculations? jonas.thornvall@gmail.com - 2016-01-11 08:28 -0800
Re: Improve speed calculations? jonas.thornvall@gmail.com - 2016-01-11 06:48 -0800
csiph-web