Re: Time Calculations

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Jerry W. Lewis (post_a_reply_at_no_e-mail.com)
Date: 04/18/04


Date: Sun, 18 Apr 2004 18:03:58 GMT

Re the math issue: Suppose
A1 = 7:00am = 7/24
A2 = 6:00am = 6/24
=(A1-A2-1/24)
returns 2.08E-17 instead of zero. This is not a math error.

Neither 7/24 nor 6/24 can be exactly represented in binary (much as
there is no exact decimal fraction representation for 1/3 You start with
0.3333, but you have to stop somewhere ...). The answer of 2.08E-17 is
the exact answer to a math problem that only approximates the math
problem that you intended. You run into these issues on any computer
that does binary floating point arithmetic (almost all software on
almost all hardware). As a result, requiring exact equality on
comparisons from non integer calculations is unrealistic.

Jerry

Matt wrote:

> Jerry
> Im not quite sure what you are saying but I guess I can use what I have. Wasnt sure if there was a way to do it through funtions or not.
> Thanks for the response
> Matt



Relevant Pages

  • Re: how do I get more numbers past the decimal?
    ... It doesn't matter what language you are using - you will NEVER get exact ... You will also never get exact results for some math operations, ... If you like the simplest example of a chaotic system is balancing a pencil on its point, and working out which way it will fall. ... Never mind the maths, you know it depends on the draught that sets it in motion, or the precision with which you can balance it. ...
    (comp.lang.php)
  • Re: IF DEAD, GOTO 10-3-39
    ... mathematically its the exact same thing. ... The original topic was how FORTRAN finally ... made math computation easily manageable. ... tortuous COBOL, and even that is a pain in the ass. ...
    (rec.sport.football.college)
  • Re: This calculation is just wrong / computer cant count!
    ... By your standards it could be argued that .83333333333333 is not correct because you can always add another 3 to the end so unless you can take the decimal places to infinity you can not have an exact value. ... Again I stress that nothing beyond the second decimal point counts and to try to include values beyond the proper number of significant digits is just plain wrong. ... Then you need to go back to primary school mathematics classes! ... Millions of PCs need to be recalled because "the math is wrong". ...
    (microsoft.public.vc.mfc)
  • Re: Age Of Universe
    ... Basic math using fractions is 100% exact. ... PLease keep in mind that the electron is ... Yousaid that you can divide anything ...
    (sci.physics)
  • Re: IF DEAD, GOTO 10-3-39
    ... mathematically its the exact same thing. ... prefix and postfix notation. ... SUBTRACT Y FROM C GIVING C. ... and it is certainly no less "math friendly". ...
    (rec.sport.football.college)