Floating Point Issues



I need to evaluate an expression of the form AB-CD and I only need the
fractional portion of the result. Unfortunately, A and B are of the
order 10^6, C is of the order 10^9 and D is of the order 10^-1. So
when I go to form my sum, which is of the order 10^12, I only get a
few digits of precision in the fractional portion (which is all I care
about). Does anyone know of a trick to help alleviate this? I
suppose I could use a higher precision data type. I'm currently using
double precision but I could try a long double or some higher-
precision package.

Thanks in advance,
Bill
.



Relevant Pages

  • Re: Floating Point Issues
    ... Bill Woessner wrote: ... I need to evaluate an expression of the form AB-CD and I only need the ... few digits of precision in the fractional portion (which is all I care ... suppose I could use a higher precision data type. ...
    (sci.math.num-analysis)
  • Re: Floating Point Issues
    ... few digits of precision in the fractional portion (which is all I care ... suppose I could use a higher precision data type. ... this list of conditions and the following disclaimer in the ... THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ...
    (sci.math.num-analysis)
  • Re: Floating Point Issues
    ... Bill Woessner wrote: ... few digits of precision in the fractional portion (which is all I care ... suppose I could use a higher precision data type. ... This should get you a few more digits, and probably as many digits as you can reasonably expect to get from your computation. ...
    (sci.math.num-analysis)
  • Re: Problem with printf formats
    ... Let P equal the precision if nonzero, 6 if the precision is omitted, or 1 if the precision is zero. ... if a conversion with style E would have an exponent of X: ... Finally, unless the # flag is used, any trailing zeros are removed from the fractional portion of the result and the decimal-point character is removed if there is no fractional portion remaining. ...
    (comp.lang.c)