[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-gnucap] insufficient limits checking in tanh model

From: mcmahill
Subject: [Bug-gnucap] insufficient limits checking in tanh model
Date: Sat, 5 Apr 2003 16:10:54 -0500 (EST)

Hi Al,

I've been looking at gnucap-0.33 a little and it seems that the bm_tanh.cc
file has a potential problem on some systems.  In this function:

void EVAL_BM_TANH::tr_eval(ELEMENT* d)const
  double x = ioffset(d->_y0.x);
  double aa = x * _gain/_limit;
  double cosine = cosh(aa);
  double f1 = _gain / (cosine*cosine);
  double f0 = _limit * tanh(aa);
  d->_y0 = FPOLY1(x, f0, f1);
  tr_final_adjust(&(d->_y0), d->f_is_value());

its possible for 'aa' to be large enough to overflow cosh and product
'inf' as the result.  Then you're relying on _gain / (inf * inf) to give
0.  In particular I've noticed that on an alpha system (alpha processors
do not implement full IEEE 754 math in hardware) I get floating point
exceptions at that line of the code.  If I compile with the -mieee flag to
gcc, traps are generated in the code to allow the software floating point
completion code to kick in and the program runs without generating the
SIGFPE's that I was getting before.  However, not all systems implement
this sort of floating point math so you may find problems on some systems.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]