Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #27438
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!us.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!newsfeed.straub-nv.de!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Ben Bacarisse <ben.lists@bsb.me.uk> |
| Newsgroups | comp.lang.javascript |
| Subject | Re: Overflow, integers and strings |
| Date | Thu, 30 Apr 2015 20:36:45 +0100 |
| Organization | A noiseless patient Spider |
| Lines | 52 |
| Message-ID | <877fst8l2q.fsf@bsb.me.uk> (permalink) |
| References | <e7aac5c2-b226-44f4-a77f-fa284c3877ba@googlegroups.com> <09495c64-e320-46ca-a6d9-b9f0427c7efd@googlegroups.com> <66061bf2-9092-42a5-918e-5a039a53db20@googlegroups.com> <XnsA48C8AB5EE74Ceejj99@194.109.133.246> |
| Mime-Version | 1.0 |
| Content-Type | text/plain |
| Injection-Info | mx02.eternal-september.org; posting-host="017616aa25f81ec581c44d76d61ba2f3"; logging-data="11149"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18xgtFAJDeD/7YLz5tINYiqjHoVZ0fbb1o=" |
| Cancel-Lock | sha1:cuAHp0h2M9Vjm2YcCKts11V34ss= sha1:UUQZCLN3M4gJJooIZaVXFiDN0tQ= |
| X-BSB-Auth | 1.1c24de560ed6dee12296.20150430203645BST.877fst8l2q.fsf@bsb.me.uk |
| Xref | csiph.com comp.lang.javascript:27438 |
Show key headers only | View raw
"Evertjan." <exxjxw.hannivoort@inter.nl.net> writes:
<snip>
> The whole lacks logic, code-beauty and perhaps speed,
> please try:
>
> function arrCompareSmaller(A, B) {
>
> var AA = A.length;
> var BB = B.length;
>
> if(AA > BB)
> return false; // greater
>
> if(AA < BB)
> return true; // smaller
>
> // so: AA == BB
> for(i = AA - 1; i > -1; i-- )
(missing var)
> if(A[i] > B[i])
> return false // greater
> else
> if(A[i] < B[i])
> return true; // smaller
>
> return false; // because is equal
>
> };
You've made the main points I was going to make, but, for what it's
worth, I was going to suggest this:
function arrCompareSmaller(A, B)
{
var alen = A.length, blen = B.length;
if (alen == blen) {
var i = alen - 1;
while (i >= 0 && A[i] == B[i]) --i;
return i >= 0 && A[i] < B[i];
}
else return alen < blen;
}
and remark that the OP seems to be ignoring negative numbers, but I
don't suppose he's bothered by that.
<snip>
--
Ben.
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Overflow, integers and strings jonas.thornvall@gmail.com - 2015-04-30 00:11 -0700
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-04-30 01:29 -0700
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-04-30 03:31 -0700
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-04-30 03:33 -0700
Re: Overflow, integers and strings "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-04-30 13:38 +0200
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-04-30 08:20 -0700
Re: Overflow, integers and strings "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-04-30 20:37 +0200
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-04-30 23:46 -0700
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-01 01:01 -0700
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-01 01:47 -0700
Re: Overflow, integers and strings "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-01 10:50 +0200
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-01 02:04 -0700
Re: Overflow, integers and strings Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-05-01 11:08 +0100
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-01 04:43 -0700
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-01 04:46 -0700
Re: Overflow, integers and strings "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-01 10:48 +0200
Re: Overflow, integers and strings Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-05-01 10:58 +0100
Re: Overflow, integers and strings "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-01 14:34 +0200
Re: Overflow, integers and strings "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-01 14:47 +0200
Re: Overflow, integers and strings "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-05-01 15:04 +0200
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-01 06:18 -0700
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-01 06:24 -0700
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-01 06:49 -0700
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-01 07:00 -0700
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-01 07:17 -0700
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-01 07:21 -0700
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-01 07:37 -0700
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-01 11:27 -0700
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-01 12:34 -0700
Re: Overflow, integers and strings Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-05-01 22:42 +0200
Re: Overflow, integers and strings "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-05-01 23:37 +0200
Re: Overflow, integers and strings "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-02 00:19 +0200
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-02 05:50 -0700
Re: Overflow, integers and strings Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-05-02 14:21 +0100
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-03 04:30 -0700
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-03 07:12 -0700
Re: Overflow, integers and strings Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-05-03 16:45 +0100
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-03 09:17 -0700
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-03 09:22 -0700
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-04 03:38 -0700
Re: Overflow, integers and strings Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-05-04 14:01 +0100
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-04 06:41 -0700
Re: Overflow, integers and strings Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-05-04 15:39 +0100
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-04 07:48 -0700
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-04 06:49 -0700
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-04 07:25 -0700
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-04 08:26 -0700
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-04 08:59 -0700
Re: Overflow, integers and strings Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-05-05 00:59 +0100
Re: Overflow, integers and strings Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-05-04 15:28 +0100
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-04 07:34 -0700
Re: Overflow, integers and strings Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-05-04 15:41 +0100
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-04 07:52 -0700
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-04 08:03 -0700
Re: Overflow, integers and strings "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-04 17:56 +0200
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-04 09:04 -0700
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-04 09:21 -0700
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-04 09:38 -0700
Re: Overflow, integers and strings "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-04 21:07 +0200
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-04 12:25 -0700
Re: Overflow, integers and strings "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-04 21:43 +0200
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-04 12:46 -0700
Re: Overflow, integers and strings "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-04 22:11 +0200
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-04 12:53 -0700
Re: Overflow, integers and strings "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-04 22:23 +0200
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-04 13:40 -0700
Re: Overflow, integers and strings "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-04 23:12 +0200
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-04 13:06 -0700
Re: Overflow, integers and strings "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-04 22:39 +0200
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-04 13:42 -0700
Re: Overflow, integers and strings Scott Sauyet <scott.sauyet@gmail.com> - 2015-05-04 13:40 -0700
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-04 13:47 -0700
Re: Overflow, integers and strings "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-04 23:30 +0200
Re: Overflow, integers and strings "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-05-04 23:33 +0200
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-04 15:53 -0700
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-04 13:51 -0700
Re: Overflow, integers and strings Scott Sauyet <scott.sauyet@gmail.com> - 2015-05-04 18:00 -0700
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-04 18:22 -0700
Re: Overflow, integers and strings Scott Sauyet <scott.sauyet@gmail.com> - 2015-05-04 21:38 -0700
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-04 18:37 -0700
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-04 14:00 -0700
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-04 09:19 -0700
Re: Overflow, integers and strings "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-04 21:24 +0200
Re: Overflow, integers and strings wolfgang zeidler <invalid@invalid.invalid> - 2015-05-04 21:37 +0200
Re: Overflow, integers and strings "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-04 21:56 +0200
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-04 13:21 -0700
Re: Overflow, integers and strings wolfgang zeidler <invalid@invalid.invalid> - 2015-05-04 22:38 +0200
Re: Overflow, integers and strings "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-04 22:46 +0200
Re: Overflow, integers and strings "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-05-04 22:57 +0200
Re: Overflow, integers and strings "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-04 23:17 +0200
Re: Overflow, integers and strings Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-05-05 00:45 +0100
Re: Overflow, integers and strings "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-05-06 00:01 +0200
Re: Overflow, integers and strings Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-05-05 08:14 +0200
Re: Overflow, integers and strings "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-05-05 23:54 +0200
Re: Overflow, integers and strings wolfgang zeidler <invalid@invalid.invalid> - 2015-05-04 23:18 +0200
Re: Overflow, integers and strings "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-04 23:53 +0200
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-04 16:06 -0700
Re: Overflow, integers and strings "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-05 10:26 +0200
Re: Overflow, integers and strings Dr J R Stockton <reply1500@merlyn.demon.co.uk.invalid> - 2015-05-05 19:59 +0100
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-04 07:40 -0700
Re: Overflow, integers and strings Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-05-05 01:10 +0100
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-01 05:03 -0700
Re: Overflow, integers and strings Ben Bacarisse <ben.lists@bsb.me.uk> - 2015-04-30 20:36 +0100
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-04-30 13:08 -0700
Re: Overflow, integers and strings Scott Sauyet <scott.sauyet@gmail.com> - 2015-04-30 10:52 -0700
csiph-web