Square Root Madness !

John D. McCalpin mccalpin at MASIG1.OCEAN.FSU.EDU
Sat Jul 9 03:53:13 AEST 1988


And you thought the exp() function had trouble --- look at what happens
when you give a negative argument to sqrt() while using the floating-point
accelerator ! Probably not what you expected!  By the way, this gives 
reasonable results without the fpa....
-------------------------------------------------------------------------
	program test
#include <fortfpe.h>
	call setfpe ( 0, 0 )
	do 10 i=-9,9
		print *, float(i), sqrt(float(i))
  10	continue
	end
-------------------------------------------------------------------------
 -9.000000   -6.159989
 -8.000000   -3.464574
 -7.000000   +5.890877
 -6.000000   +2.086059E+01
 -5.000000   -8.948573
 -4.000000   -2.449822
 -3.000000   +1.475061E+01
 -2.000000   -1.732287
 -1.000000   -1.224911
 +0.000000E+00   +0.000000E+00
 +1.000000   +1.000000
 +2.000000   +1.414214
 +3.000000   +1.732051
 +4.000000   +2.000000
 +5.000000   +2.236068
 +6.000000   +2.449490
 +7.000000   +2.645751
 +8.000000   +2.828427
 +9.000000   +3.000000
-------------------------------------------------------------------------
John D. McCalpin
mccalpin at nu.cs.fsu.edu



More information about the Comp.sys.sgi mailing list