Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!news.solani.org!.POSTED!not-for-mail From: "Christoph M. Becker" Newsgroups: comp.lang.javascript Subject: Re: Best search algorithm to find a condition within a range. Date: Thu, 09 Apr 2015 14:55:42 +0200 Organization: solani.org Lines: 20 Message-ID: References: <87vbh8yvgv.fsf@bsb.me.uk> <777f7633-724b-442e-864b-d6484c5e87cf@googlegroups.com> <87pp7gysv5.fsf@bsb.me.uk> <2186a589-be06-4453-affc-3c84f9e48379@googlegroups.com> <87egnwymxr.fsf@bsb.me.uk> <2016084.ADp8TKvx9G@PointedEars.de> <5902185.dpbNY2YNC7@PointedEars.de> <1936096.bgrWbIOXpn@PointedEars.de> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Trace: solani.org 1428584135 8773 eJwFwQkRADAIAzBLfC0gZ9uBfwlL4FS+DIKBxYpdR104262wT227Yki0VTZmWolRXwk5+QH5yQ/N (9 Apr 2015 12:55:35 GMT) X-Complaints-To: abuse@news.solani.org NNTP-Posting-Date: Thu, 9 Apr 2015 12:55:35 +0000 (UTC) User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 X-User-ID: eJwNwgERADEIAzBLYx0F9AD1L+E/FweNHY/O53LZJjiCQt1VN5UHHdx/nYZxruwoF1E1+AAf0RD5 In-Reply-To: Cancel-Lock: sha1:cV0qXdxQl2Y85t3rfhs2CcqApZ0= X-NNTP-Posting-Host: eJwNyMEBwCAIA8CVxBAo40QL+4/Q3vOIsLjpwXAOx0VQdreqlXfp/4leJXlbtakMJ3Fe5C48HyC6EPc= Xref: csiph.com comp.lang.javascript:27262 Evertjan. wrote: > The advice given was to add zero's in front of the "shortest" stringified > number. > > There is no way to do that without first retrieving the "length" of both > and assessing the difference to know how many zerows to add. > > So the length difference so already there, and there is no need to add the > zero characters when this difference != 0, since that value already answers > the comparison. And there is no need to add them when they are equal too, > btw. Why would someone try to do integer arithmetic on strings? I would suggest to use a large base, where each digit is an element of an array. IIRC Ben (Bacarisse) has already suggest this. -- Christoph M. Becker