[comp.sys.sequent] Arrgh, Floating Point exception on sequent! Help!

cluther@ponder.csci.unt.edu (Clay Luther) (05/30/91)

I cannot figure this one out.  My program is generating a floating point
exception when testing two valid float numbers.  Here is the code...

   40     int r1, r2;
   41     float fval;
   42     float tval;
   43
   44     r1 = (int)x;
   45     tval = (x - r1);
   46     fval = float_rand();
   47     r2 = r1+1;
   48     if ( fval > tval ) {
   49       return r1;
   50     } else {
   51       return r2;
   52     }

x is register float, and is passed into the function.  Originally, I had the
function written simply as:

return ( ( float_rand() > x-(int)x ) ? (int)x : (int)(x+1) );

but that generated a fp error.  I expanded it so I could look at each step.
The error occurs on line 48

  if ( fval > tval ) {

WHY?

Dbx informs that both fval and tval have reasonable values.  But this test just
doesn't work.

Confused.

-- 
Clay Luther                         Lonely C++ Programmer        
cluther@ponder.csci.unt.edu
cluther@solo.csci.unt.edu           I work here now and they still
cluther@supernet.haus.com           don't let me have any opinions.