Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #27244
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: Best search algorithm to find a condition within a range. |
| Date | 2015-04-07 19:58 +0100 |
| Organization | A noiseless patient Spider |
| Message-ID | <878ue3zrws.fsf@bsb.me.uk> (permalink) |
| References | (2 earlier) <777f7633-724b-442e-864b-d6484c5e87cf@googlegroups.com> <87pp7gysv5.fsf@bsb.me.uk> <2186a589-be06-4453-affc-3c84f9e48379@googlegroups.com> <87egnwymxr.fsf@bsb.me.uk> <ae7ffc61-7f66-4f0e-a53a-31b555287f45@googlegroups.com> |
jonas.thornvall@gmail.com writes: > Den tisdag 7 april 2015 kl. 17:31:49 UTC+2 skrev Ben Bacarisse: >> jonas.thornvall@gmail.com writes: >> >> > Den tisdag 7 april 2015 kl. 15:23:47 UTC+2 skrev Ben Bacarisse: >> >> jonas.thornvall@gmail.com writes: >> <snip> >> >> > I aim to replace the slow add when dealing with real big bases with a >> >> > search. >> >> >> >> I thought your post was about converting between bases. If it wasn't, >> >> just ignore my comments. >> > >> > It is about converting bases as fast as possible in a general way that >> > work for anybase no matter how ***big***. That mean you cannot add up >> > digits, it is to slow you have to search the digit, doing a binary >> > search or something better. >> >> Then my point stands. Why are you "searching" for a digit rather than >> simply calculating it? Have you determined that the usual method is too >> slow and you have some alternative in mind? > > Yes the binary search have better time than linear add. > > Example base 4294967295 That's a very odd base to use. 4294967296 would, on the other hand, be quite a reasonable choice in some contexts. Not for ECMAScript, though, because, in general, the best base to use is the largest one where you can get an exact product of two digits from the underlying programming environment. > number = > 3243787983738733984329847327432738783449058438543890486865659065465474857454395 > > Find value of first digitplace (higest), using commaseparated notation > it will be a value between 1 and (4294967295-1) It's 28. If you want to represent that number in the specified base, you should just generate the digits as normal -- taking the remainder and dividing. You have invented a problem that can be avoided altogether if you choose not to find the most significant digit first. If, however, you only want to find the leading digit, there may be a better way, but it's likely to use logarithms: log(3243787...54395)/log(4294967295) = 8.15.. floor(3243787...54395 / 4294967295^8) = 28 -- Ben.
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Best search algorithm to find a condition within a range. jonas.thornvall@gmail.com - 2015-04-07 02:43 -0700
Re: Best search algorithm to find a condition within a range. "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-04-07 13:07 +0200
Re: Best search algorithm to find a condition within a range. jonas.thornvall@gmail.com - 2015-04-07 04:38 -0700
Re: Best search algorithm to find a condition within a range. jonas.thornvall@gmail.com - 2015-04-07 04:48 -0700
Re: Best search algorithm to find a condition within a range. "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-04-07 14:49 +0200
Re: Best search algorithm to find a condition within a range. Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-04-07 13:27 +0100
Re: Best search algorithm to find a condition within a range. jonas.thornvall@gmail.com - 2015-04-07 06:04 -0700
Re: Best search algorithm to find a condition within a range. Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-04-07 14:23 +0100
Re: Best search algorithm to find a condition within a range. jonas.thornvall@gmail.com - 2015-04-07 06:54 -0700
Re: Best search algorithm to find a condition within a range. Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-04-07 16:31 +0100
Re: Best search algorithm to find a condition within a range. jonas.thornvall@gmail.com - 2015-04-07 08:59 -0700
Re: Best search algorithm to find a condition within a range. Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-04-07 19:58 +0100
Re: Best search algorithm to find a condition within a range. Dr J R Stockton <reply1500@merlyn.demon.co.uk.invalid> - 2015-04-09 23:08 +0100
Re: Best search algorithm to find a condition within a range. Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-04-10 00:02 +0100
Re: Best search algorithm to find a condition within a range. Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-04-07 18:37 +0200
Re: Best search algorithm to find a condition within a range. jonas.thornvall@gmail.com - 2015-04-07 09:55 -0700
Re: Best search algorithm to find a condition within a range. "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-04-07 20:30 +0200
Re: Best search algorithm to find a condition within a range. Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-04-07 20:58 +0200
Re: Best search algorithm to find a condition within a range. "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-04-07 22:19 +0200
Re: Best search algorithm to find a condition within a range. jonas.thornvall@gmail.com - 2015-04-08 00:14 -0700
Re: Best search algorithm to find a condition within a range. "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-04-08 10:55 +0200
Re: Best search algorithm to find a condition within a range. Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-04-09 13:03 +0200
Re: Best search algorithm to find a condition within a range. "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-04-09 14:11 +0200
Re: Best search algorithm to find a condition within a range. "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-04-09 14:55 +0200
Re: Best search algorithm to find a condition within a range. "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-04-09 15:20 +0200
Re: Best search algorithm to find a condition within a range. Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-04-09 14:49 +0100
Re: Best search algorithm to find a condition within a range. Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-04-09 16:10 +0200
Re: Best search algorithm to find a condition within a range. "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-04-09 16:17 +0200
Re: Best search algorithm to find a condition within a range. jonas.thornvall@gmail.com - 2015-04-09 07:22 -0700
Re: Best search algorithm to find a condition within a range. "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-04-09 16:44 +0200
Re: Best search algorithm to find a condition within a range. jonas.thornvall@gmail.com - 2015-04-09 07:57 -0700
Re: Best search algorithm to find a condition within a range. jonas.thornvall@gmail.com - 2015-04-09 08:05 -0700
Re: Best search algorithm to find a condition within a range. Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-04-09 17:04 +0100
Re: Best search algorithm to find a condition within a range. Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-04-09 16:14 +0200
Re: Best search algorithm to find a condition within a range. "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-04-09 16:34 +0200
Re: Best search algorithm to find a condition within a range. Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-04-09 17:39 +0200
Re: Best search algorithm to find a condition within a range. "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-04-09 18:04 +0200
Re: Best search algorithm to find a condition within a range. Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-04-09 18:26 +0200
Re: Best search algorithm to find a condition within a range. "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-04-09 22:13 +0200
Re: Best search algorithm to find a condition within a range. jonas.thornvall@gmail.com - 2015-04-07 10:00 -0700
Re: Best search algorithm to find a condition within a range. jonas.thornvall@gmail.com - 2015-04-07 06:16 -0700
Re: Best search algorithm to find a condition within a range. "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-04-07 15:28 +0200
Re: Best search algorithm to find a condition within a range. jonas.thornvall@gmail.com - 2015-04-07 06:58 -0700
Re: Best search algorithm to find a condition within a range. "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-04-07 20:25 +0200
Re: Best search algorithm to find a condition within a range. Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-04-07 14:33 +0100
csiph-web