In comp.lang.pascal.borland message <mk1um3t3oms8ubqdqmgqq1ko2h3ks73vc8@[EMAIL PROTECTED]
>, Mon, 24 Dec 2007 01:10:29, Jim Higgins
<invalid@[EMAIL PROTECTED]
> posted:
>
>Assuming price and tax are really meant to be integers, you need to
>define total as real or you'll be unable to lose precision.
>
>An item with a PRICE of $4 at a TAX RATE of 6% will have a TOTAL COST
>of $4.24 due to the added TAX AMOUNT of $0.24. Your variables that
>hold these assorted values must be data types that will hold the value
>without losing accuracy or precision.
The value 0.24 cannot be held exactly in a real, single, double, or
extended. The nearest Single value is +0.23999999463558197021484375.
It can be held exactly in a comp. But direct use of a comp is not
always adequate - lawful conversion of punts to euros required division
by 0.787564 to specified accuracy.
In practice, one must either use exact arithmetic throughout, or accept
inexactness - and control the consequences.
--
(c) John Stockton, Surrey, UK. ?@[EMAIL PROTECTED]
Turnpike v6.05
MIME.
<URL:http://www.merlyn.demon.co.uk/>
TP/BP/Delphi/&c., FAQqy topics &
links;
<URL:http://www.merlyn.demon.co.uk/clpb-faq.txt>
RAH Prins : c.l.p.b
mFAQ;
<URL:ftp://garbo.uwasa.fi/pc/link/tsfaqp.zip> Timo Salmi's Turbo Pascal
FAQ.


|