[comp.sys.sgi] Floating point problems

marvil@tigger.colorado.edu (Rebecca Marvil) (08/11/89)

I've been having floating point problems on an Iris 2400 turbo 
running version GL2-W3.5, and was wondering if anyone can help.

The problem is that floating point operations do not work
properly.  I first noticed this when I tried to print a 
float variable as follows: 

	float x = 0.5;
	printf("x = %f",x);

When execution reaches the printf statement, it hangs on the
%f.  Using dbx, I ran the program, then typed CTRL-C after execution
stopped at the %f, and found that the program was hung in the
subroutine '_sw_f_div()'.

I've also found that float variables cannot be added or subtracted
accurately (it seems to be a problem with the sign).  Also, 
opposite signed floats are thought to be equal (ie.  0.01 is equal
to -0.01).  

Conversions also don't work properly.  For instance, if
I cast a float variable to an int, the result is the correct integer
value, but the sign is always negative, whether or not the original
float was negative.  Also, if I use atof(), I don't get the correct float
result.

If anyone has a clue as to what my problem is, I would appreciate
a response.  One possibility, I suppose, is that the fpa board
is screwed up.  If so, is there a way to bypass this board and
have the software do floating point operations?

Thanks in advance for any suggestions,

Becky Marvil			
Dept of MCD Biology		email:  marvil@boulder.colorado.edu
University of Colorado
Boulder, CO 80309
(303)-492-3600

fsfacca@LERC08.LERC.NASA.GOV (Tony Facca) (08/11/89)

[Becky Marvil] writes:

> I've been having floating point problems on an Iris 2400 turbo 
> running version GL2-W3.5, and was wondering if anyone can help.

  [ stuff about floating point problems deleted ]

> If anyone has a clue as to what my problem is, I would appreciate
> a response.  One possibility, I suppose, is that the fpa board
> is screwed up.  If so, is there a way to bypass this board and
> have the software do floating point operations?

We've had similar problems in the past on our 3030's and in every instance
it turned out to be the fpa board.  A quick check that we use is a simple
program which loops from 0 to 100 and prints out the integer and floating
point value at each interation.  Its written on FORTRAN so we compile it
first with, then without the floating point option:

   [with]  f77 -Zg prog.f -o prog

   [w/o]   f77 prog.f -o prog

I wish I had a bad fpa board to test this on :)  but I think that's how we
found the problem.  I'll send the source directly rather than posting it
here..  

Hope this helps..


--
-----------------------------------------------------------------------------
Tony Facca                     |     phone: 216-433-8318
NASA Lewis Research Center     |    
Cleveland, Ohio  44135         |     email: fsfacca@lerc08.lerc.nasa.gov
-----------------------------------------------------------------------------