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


Groups > comp.lang.java.programmer > #14372

Re: Sorting numeric strings

Path csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail
From Joshua Cranmer <Pidgeot18@verizon.invalid>
Newsgroups comp.lang.java.programmer
Subject Re: Sorting numeric strings
Date Mon, 07 May 2012 12:38:08 -0500
Organization A noiseless patient Spider
Lines 16
Message-ID <jo91aa$cm7$1@dont-email.me> (permalink)
References <CqVnr.242$go4.98@newsfe14.iad> <0km0q7lrv910pkbfb1lidbdfr3bkfjglui@4ax.com> <uKednQ89I8TCwD3SnZ2dnUVZ_sCdnZ2d@earthlink.com> <3s93q719q1787gb4ihi4fugvn8cvgc8nu2@4ax.com> <iuUHyzEIFtoPFwwg@invalid.uk.co.demon.merlyn.invalid> <n296q79vcj1hoi8vunmqem2nbe1litv4av@4ax.com> <29053378.63.1336093904131.JavaMail.geo-discussion-forums@pbctc10> <jo1cje$o4a$1@localhost.localdomain> <gkh8q712jvs0scpgtil3ull4cssmis5v1k@4ax.com> <jo1p6k$ra8$2@localhost.localdomain> <pj1gq7tjiuh46n06r2m05iprf0vbvihm70@4ax.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding 7bit
Injection-Date Mon, 7 May 2012 17:38:18 +0000 (UTC)
Injection-Info mx04.eternal-september.org; posting-host="WpcHJSul77m+zlbR9GVqkA"; logging-data="12999"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19RGN3wWvOK+6NaNvYl22ubseAz8oeRbO8="
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20120428 Thunderbird/12.0.1
In-Reply-To <pj1gq7tjiuh46n06r2m05iprf0vbvihm70@4ax.com>
Cancel-Lock sha1:fA8MGzUAAtnvefDVPR18VZVXf/o=
Xref csiph.com comp.lang.java.programmer:14372

Show key headers only | View raw


On 5/7/2012 12:34 PM, Gene Wirchenko wrote:
>       Floating point can represent some integer values exactly.  The
> IEEE 754 64-bit format has 53 bits of precision.  This is not quite 16
> digits of precision.  Stick with integer values in the range
> (-10^15,10^15) (an exclusive range), and they will all be represented
> exactly.

Or, another way to look at it, double arithmetic can represent exactly 
every value which would be a Java int, which means if you would normally 
use an int in the first place, you can use a double instead (with tweaks 
needed for division). Indeed, many JS JITs will do arithmetic as 
integers if the numbers are integral.

-- 
Beware of bugs in the above code; I have only proved it correct, not 
tried it. -- Donald E. Knuth

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Sorting numeric strings Ben <no@way.com> - 2012-04-30 21:27 -0400
  Re: Sorting numeric strings Arne Vajhøj <arne@vajhoej.dk> - 2012-04-30 21:39 -0400
  Re: Sorting numeric strings Gene Wirchenko <genew@ocis.net> - 2012-05-01 10:30 -0700
  Re: Sorting numeric strings Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-05-01 10:53 -0700
    Re: Sorting numeric strings Roedy Green <see_website@mindprod.com.invalid> - 2012-05-01 14:50 -0700
      Re: Sorting numeric strings Patricia Shanahan <pats@acm.org> - 2012-05-01 15:02 -0700
        Re: Sorting numeric strings Roedy Green <see_website@mindprod.com.invalid> - 2012-05-02 14:36 -0700
          Re: Sorting numeric strings Gene Wirchenko <genew@ocis.net> - 2012-05-02 19:57 -0700
          Re: Sorting numeric strings Dr J R Stockton <reply1218@merlyn.demon.co.uk.not.invalid> - 2012-05-03 19:41 +0100
            Re: Sorting numeric strings Roedy Green <see_website@mindprod.com.invalid> - 2012-05-03 17:40 -0700
              Re: Sorting numeric strings Lew <lewbloch@gmail.com> - 2012-05-03 18:11 -0700
                Re: Sorting numeric strings Martin Gregorie <martin@address-in-sig.invalid> - 2012-05-04 20:01 +0000
                Re: Sorting numeric strings Gene Wirchenko <genew@ocis.net> - 2012-05-04 14:19 -0700
                Re: Sorting numeric strings Martin Gregorie <martin@address-in-sig.invalid> - 2012-05-04 23:36 +0000
                Re: Sorting numeric strings Dr J R Stockton <reply1218@merlyn.demon.co.uk.not.invalid> - 2012-05-06 17:50 +0100
                Re: Sorting numeric strings Gene Wirchenko <genew@ocis.net> - 2012-05-07 10:34 -0700
                Re: Sorting numeric strings Joshua Cranmer <Pidgeot18@verizon.invalid> - 2012-05-07 12:38 -0500
                Re: Sorting numeric strings glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2012-05-07 17:48 +0000
                Re: Sorting numeric strings Gene Wirchenko <genew@ocis.net> - 2012-05-07 11:42 -0700
  Re: Sorting numeric strings Roedy Green <see_website@mindprod.com.invalid> - 2012-05-01 13:38 -0700

csiph-web