🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.sequent
Article #590

Arrgh, Floating Point exception on sequent! Help!

#590
From: Clay Luther
Date: Wed, 29 May 1991 20:05
39 lines
1550 bytes
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.
Technical Details
Message-ID: <cluther.675547508@ponder>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!cs.utexas.edu!solo.csci.unt.edu!ponder!cluther

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!cs.utexas.edu!solo.csci.unt.edu!ponder!cluther
From: cluther@ponder.csci.unt.edu (Clay Luther)
Newsgroups: comp.sys.sequent
Subject: Arrgh,  Floating Point exception on sequent!  Help!
Message-ID: <cluther.675547508@ponder>
Date: 29 May 91 20:05:08 GMT
Sender: usenet@solo.csci.unt.edu (Usenet News)
Organization: University of North Texas, Denton
Lines: 39