Path: csiph.com!usenet.pasdenom.info!news.alphanet.ch!alphanet.ch!news.imp.ch!news.albasani.net!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: Gene Wirchenko Newsgroups: comp.lang.java.programmer Subject: Re: Sorting numeric strings Date: Fri, 04 May 2012 14:19:51 -0700 Organization: A noiseless patient Spider Lines: 27 Message-ID: References: <2012043021273098748-no@waycom> <0km0q7lrv910pkbfb1lidbdfr3bkfjglui@4ax.com> <3s93q719q1787gb4ihi4fugvn8cvgc8nu2@4ax.com> <29053378.63.1336093904131.JavaMail.geo-discussion-forums@pbctc10> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Injection-Info: mx04.eternal-september.org; posting-host="wKah3EH8kutwAOV6+9FiEQ"; logging-data="2368"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/0zk8ohDM5X7DmpyrTcyfjQzvKNJKn2OY=" X-Newsreader: Forte Agent 4.2/32.1118 Cancel-Lock: sha1:JcUxw9H01Y9nQCilc3yTsPXDh4Q= Xref: csiph.com comp.lang.java.programmer:14270 On Fri, 4 May 2012 20:01:50 +0000 (UTC), Martin Gregorie wrote: [snip] >I think you'll find that using floating point for financial amounts was >an abberation introduced by programmers on early 8 and 16 bit micros who >wrote financial packages in BASIC. I suspect that it raised its head on earlier systems that did not have COBOL or another language with decimal arithmetic. With JavaScript, short of writing a fixed-point library, you have to use floating point since JavaScript has only one numeric type, namely IEEE 754 64-bit floating point. If you restrict your arithmetic such that calculations result only in integer values in range, you are safe. I have done proof-of-concept on this, and it does work. >Early mainframes stored currency values as binary or BCD integers and all >modern systems should do the same The details are the killer. Sincerely, Gene Wirchenko