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


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

Re: Sorting numeric strings

From Lew <lewbloch@gmail.com>
Newsgroups comp.lang.java.programmer
Subject Re: Sorting numeric strings
Date 2012-05-03 18:11 -0700
Organization http://groups.google.com
Message-ID <29053378.63.1336093904131.JavaMail.geo-discussion-forums@pbctc10> (permalink)
References (2 earlier) <0km0q7lrv910pkbfb1lidbdfr3bkfjglui@4ax.com> <uKednQ89I8TCwD3SnZ2dnUVZ_sCdnZ2d@earthlink.com> <3s93q719q1787gb4ihi4fugvn8cvgc8nu2@4ax.com> <iuUHyzEIFtoPFwwg@invalid.uk.co.demon.merlyn.invalid> <n296q79vcj1hoi8vunmqem2nbe1litv4av@4ax.com>

Show all headers | View raw


Roedy Green wrote:
> Dr J R Stockton wrote, quoted or indirectly quoted someone who said :
> 
>> One then only has a factor of about seven to spare if handling the US
>> annual GDP.  It's worse for the Chinese, whose yuan is cheaper than the
>> USD by a larger factor than their GDP is less, and contains 100 fen.
> 
> They won't fail catastrophically, the way longs fail.  They will just
> start getting the low order digits inaccurately, which really does not
> matter except for aesthetics.

You have an unusual understanding of accounting.

The low-order bits might matter, depending on the purpose. If you're calculating, you can get unusual results due to round-off error. If your purpose is approximate, the answers might be close enough, as you suggest. But so much of accounting requires perfect accuracy, irrespective of scale, so a catastrophic failure might be preferable to a graceful wrong answer.

Also, a 64-bit double only has 53 bits of precision; a long has 63. So arguably a long is better to represent individual amounts unless you're doing funky calculations such as for interest. You could, for example, express the Chinese GDP in fen.

But then there's BigDecimal, with perfect accuracy. So there are choices.

-- 
Lew

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