Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #12424
| From | Robert Klemme <shortcutter@googlemail.com> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: Fixed-point arithmetic library |
| Date | 2012-02-27 07:32 +0100 |
| Message-ID | <9r0mcoFjjtU1@mid.individual.net> (permalink) |
| References | <alpine.DEB.2.00.1202222012550.5334@urchin.earth.li> <9ql7jpF3mnU1@mid.individual.net> <jiekgk$g1p$1@speranza.aioe.org> <4f4ae165$0$294$14726298@news.sunsite.dk> |
On 27.02.2012 02:50, Arne Vajhøj wrote: > On 2/26/2012 7:59 PM, glen herrmannsfeldt wrote: >> Robert Klemme<shortcutter@googlemail.com> wrote: >> >> (snip) >>>> I would quite like to represent some numbers in fixed point, >>>> and do arithmetic with them. >> >>> Fixed point math is susceptible to precision issues which can >>> be more severe than those of float and double: 0.01 * 0.2 -> 0.00 >> >> In PL/I, if you multiply, you get the appropriate number if digits >> after the radix point. >> >> FIXED DECIMAL(3,2) times FIXED DECIMAL(2,1) generates a >> product of FIXED DECIMAL(5,3). If you force it to throw away >> low order digits, then, yes you can lose precision. > > That is rather similar to how BigDecimal works. And that is not exactly how FP arithmetic is described in Wikipedia: "For simplicity, fixed-point multiply procedures use the same result format as the operands. This has the effect of keeping the middle bits; the I-number of least significant integer bits, and the Q-number of most significant fractional bits. Fractional bits lost below this value represent a precision loss which is common in fractional multiplication. If any integer bits are lost, however, the value will be radically inaccurate." It boils down to how fixed "fixed" is. In my understanding decimal places are fixed throughout the whole calculation which is not what BD does (obviously to avoid precision loss). Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar
Fixed-point arithmetic library Tom Anderson <twic@urchin.earth.li> - 2012-02-22 21:39 +0000
Re: Fixed-point arithmetic library Jan Burse <janburse@fastmail.fm> - 2012-02-22 22:59 +0100
Re: Fixed-point arithmetic library Tom Anderson <twic@urchin.earth.li> - 2012-02-23 21:15 +0000
Re: Fixed-point arithmetic library markspace <-@.> - 2012-02-23 13:53 -0800
Re: Fixed-point arithmetic library Robert Klemme <shortcutter@googlemail.com> - 2012-02-23 23:21 +0100
Re: Fixed-point arithmetic library Jan Burse <janburse@fastmail.fm> - 2012-02-24 00:02 +0100
Re: Fixed-point arithmetic library Robert Klemme <shortcutter@googlemail.com> - 2012-02-22 23:13 +0100
Re: Fixed-point arithmetic library Gene Wirchenko <genew@ocis.net> - 2012-02-22 14:59 -0800
Re: Fixed-point arithmetic library Martin Gregorie <martin@address-in-sig.invalid> - 2012-02-23 01:05 +0000
Re: Fixed-point arithmetic library Tom Anderson <twic@urchin.earth.li> - 2012-02-23 21:21 +0000
Re: Fixed-point arithmetic library Gene Wirchenko <genew@ocis.net> - 2012-02-23 13:49 -0800
Re: Fixed-point arithmetic library Tom Anderson <twic@urchin.earth.li> - 2012-02-23 21:16 +0000
Re: Fixed-point arithmetic library Gene Wirchenko <genew@ocis.net> - 2012-02-23 14:03 -0800
Re: Fixed-point arithmetic library Lew <noone@lewscanon.com> - 2012-02-23 14:42 -0800
Re: Fixed-point arithmetic library Gene Wirchenko <genew@ocis.net> - 2012-02-23 15:08 -0800
Re: Fixed-point arithmetic library Martin Gregorie <martin@address-in-sig.invalid> - 2012-02-23 23:05 +0000
Re: Fixed-point arithmetic library glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2012-02-27 00:59 +0000
Re: Fixed-point arithmetic library Arne Vajhøj <arne@vajhoej.dk> - 2012-02-26 20:50 -0500
Re: Fixed-point arithmetic library Robert Klemme <shortcutter@googlemail.com> - 2012-02-27 07:32 +0100
Re: Fixed-point arithmetic library Jan Burse <janburse@fastmail.fm> - 2012-02-27 13:46 +0100
Re: Fixed-point arithmetic library Roedy Green <see_website@mindprod.com.invalid> - 2012-02-24 16:26 -0800
csiph-web