Is the 4 decimal place accuracy ever a practical problem? Laurie
On 17 June 2014 14:19, Richard Kaye <[email protected]> wrote: > I have vague memories of discussions around using the currency data type > and why it's not a good idea because its precision is limited to 4 decimal > places. You can actually end up introducing rounding errors that can be > very difficult to hunt down. If I can find the references I'll post them > back here. > > -- > > rk > -----Original Message----- > From: ProfoxTech [mailto:[email protected]] On Behalf Of > Laurie Alvey > Sent: Tuesday, June 17, 2014 3:52 AM > To: [email protected] > Subject: Re: VAT Rates > > If you modify Peter's test program like this: > > CLEAR > nNum = $0.01 > nRate = $0.21 > DO WHILE nNum < $100000 > nVat = NTOM(ROUND(nNum*nRate,2)) > nGross = NTOM(nNum + nVat) > nMulti = NTOM(ROUND(nNum*(1+nRate),2)) > IF nGross <> nMulti > ? 'Value ' + STR(nNum,9,2) + ' differs. ' + STR(nGross,10,2) + > STR(nMulti,10,2) EXIT > ENDIF > nNum = nNum + $0.01 > ENDDO > ? "Finished." > > so that all numerics are converted to CURRENCY, no errors occur. Currency > data has its own way of doing arithmetic and rounding. I always use the > Currency type for storing and computing financial transactions. > > Laurie > [excessive quoting removed by server] _______________________________________________ Post Messages to: [email protected] Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech Searchable Archive: http://leafe.com/archives/search/profox This message: http://leafe.com/archives/byMID/profox/CAMvTR9e7=3AZ7v_ruw5pFb_p_XrQB500Hd=qL_gQ-iMguDm=v...@mail.gmail.com ** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.

