Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!.POSTED!not-for-mail From: glen herrmannsfeldt Newsgroups: comp.lang.java.programmer Subject: Re: Fixed-point arithmetic library Date: Mon, 27 Feb 2012 00:59:00 +0000 (UTC) Organization: Aioe.org NNTP Server Lines: 17 Message-ID: References: <9ql7jpF3mnU1@mid.individual.net> NNTP-Posting-Host: o0XHsUYDcyyrMA9MpVIM0w.user.speranza.aioe.org X-Complaints-To: abuse@aioe.org User-Agent: tin/1.9.6-20100522 ("Lochruan") (UNIX) (Linux/2.6.32-5-amd64 (x86_64)) X-Notice: Filtered by postfilter v. 0.8.2 Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:12401 Robert Klemme 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. -- glen