Newsgroups: comp.lang.java.programmer From: "Peter J. Holzer" Subject: Re: (OT) Was: Re: Java processors References: <5f101d00-4bc9-4750-939c-cd53605bfa0e@googlegroups.com> <8i6fv7pdnb4riuvnr8a3e7t9htorgsbpm4@4ax.com> <5g2iv7l6d20bufru42qoun737bf80r6kp6@4ax.com> Date: Sun, 8 Jul 2012 12:15:46 +0200 User-Agent: slrn/pre1.0.0-18 (Linux) Message-ID: NNTP-Posting-Host: zeno.hjp.at X-Trace: 8 Jul 2012 10:23:02 GMT, zeno.hjp.at Lines: 40 Path: csiph.com!usenet.pasdenom.info!news.albasani.net!news.wsr.ac.at!zeno.hjp.at!not-for-mail Xref: csiph.com comp.lang.java.programmer:15872 On 2012-07-08 04:19, Gene Wirchenko wrote: > On Sat, 07 Jul 2012 11:38:13 -0400, Eric Sosman > wrote: >> The Wikipedia article on the VSE makes interesting reading. This >>bit I found somewhat eyebrow-raising: >> >> The history of the exchange's index provides a standard case >> example of large errors arising from seemingly innocuous >> floating point calculations. [...] The accumulated truncations >> led to an erroneous loss of around 25 points per month." >> >>Not enough RAM to retain the "unimportant" digits? > > Probably not. I would blame the use of FP. Actually, it looks like they used a *fixed point* representation (3 decimal digits), not a floating point representation (although that doesn't make much difference in this case since the magnitude stays about the same). The obvious error is that they always truncated the value, thus accumulating the error[1]. If they had rounded to nearest most errors would have cancelled out. If they had used double precision binary floating point numbers and not rounded to 3 decimal digits after each trade the error would have been too small to notice (about 1 point in 30 million years). Anyway, that's a great example. I will use it in the next "binary floating point is evil" discussion ;-). hp [1] The second error was that they tried to compute the new value from the old value and the change at all - that's pretty much guarantueed to accumulate some error over time. -- _ | Peter J. Holzer | Deprecating human carelessness and |_|_) | Sysadmin WSR | ignorance has no successful track record. | | | hjp@hjp.at | __/ | http://www.hjp.at/ | -- Bill Code on asrg@irtf.org