[vox-tech] help with signals and C

Mark K. Kim vox-tech@lists.lugod.org
Wed, 13 Mar 2002 21:27:55 -0800 (PST)


keywords: signal, signals, SIGFPE, floating point numbers, inf, nan
keywords: divide-by-zero, round-off error

Pete,

Your test program works if you do an integer division, but not for
floating point division.  I think I read on one of Jeff's links that
SIGFPE isn't just for floating point numbers, so perhaps division by zero
is caught only for integer division on x86.

I'm not sure what kind of errors your program would have if it's not
generating "inf" or "nan".  If you're getting calculations errors, I think
you're getting floating point round-off errors, rather than
overflow/underflow.  If that's the case, you'd need a higher precision
numbers (double, long double, or the arbitrary-precision numbers
library...)

One more thing - If you have a really big number plus a really small
number, the smaller number gets thrown out.  In that case, you'll need a
really high precision number type that can span across the big and the
small number to avoid the round-off error.  If you have this type of
problem, and if you can't use the high-enough precision number type
(either because you don't have one available or it's too slow), there's no
way around it except rewriting the code.

-Mark

--
Mark K. Kim
http://www.cbreak.org/
PGP key available upon request.