Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Pascal Borland > Re: Decimals an...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 5 of 5 Topic 1072 of 1118
Post > Topic >>

Re: Decimals and numbers

by Dr J R Stockton <jrs@[EMAIL PROTECTED] > Dec 24, 2007 at 09:37 PM

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.
 




 5 Posts in Topic:
Decimals and numbers
Joe <joe@[EMAIL PROTEC  2007-12-23 12:08:35 
Re: Decimals and numbers
winston19842005 <bjjly  2007-12-23 12:25:19 
Re: Decimals and numbers
Jim Higgins <invalid@[  2007-12-24 01:10:29 
Re: Decimals and numbers
Joe <joe@[EMAIL PROTEC  2007-12-24 11:42:08 
Re: Decimals and numbers
Dr J R Stockton <jrs@[  2007-12-24 21:37:33 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Thu Jul 24 23:39:49 CDT 2008.