home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.pascal.borland      Borland Pascal was actually pretty neat      2,978 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 2,585 of 2,978   
   Dr J R Stockton to All   
   Re: Decimals and numbers   
   24 Dec 07 21:37:33   
   
   From: jrs@merlyn.demon.co.uk   
      
   In comp.lang.pascal.borland message , Mon, 24 Dec 2007 01:10:29, Jim Higgins   
    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.   ?@merlyn.demon.co.uk   Turnpike v6.05   MIME.   
      TP/BP/Delphi/&c., FAQqy topics & links;   
        RAH Prins : c.l.p.b mFAQ;   
      Timo Salmi's Turbo Pascal FAQ.   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca