greg@eemips.tamu.edu (Greg Economides) (09/14/90)
I have had strange results using "rabs" and "dabs" routines. dabs is not
listed in the hardcopy library reference since it is not exported,
but it exists as a routine of SINGLE_MATH. I'm not sure why it is not
exported, but that is not really an issue here. I do not know what
is causing the strange results I am having; rabs and dabs both return
nonsense values. I wonder if something is wrong with the "C" routines
used in them. Here is a short class I wrote and its corresponding
output (notice, I wrote my own absolute value routine into the class --
myabs).
-----------------------------------------------------------------------
class TEST
inherit
BASIC;
SINGLE_MATH;
feature
Create is
local
i: INTEGER;
r, tmp: REAL;
do
r := -0.5;
io.putstring("dabs of -0.5: ");
io.putreal(dabs(r));io.new_line;
io.putstring("rabs of same: ");
io.putreal(rabs(r));io.new_line;
io.putstring("myabs of same: ");
io.putreal(myabs(r));io.new_line;
r := 0.5;
io.putstring("dabs of 0.5: ");
io.putreal(dabs(r));io.new_line;
io.putstring("rabs of same: ");
io.putreal(rabs(r));io.new_line;
io.putstring("myabs of same: ");
io.putreal(myabs(r));io.new_line;
end; -- Create
myabs (r: REAL): REAL is
do
if r < 0.0 then
Result := r*(-1.0)
else
Result := r
end -- if
end -- myabs
end; -- class TEST
--------------------------------------------------------------------------
Output is as follows:
dabs of -0.5: 0
rabs of same: -NaN
myabs of same: .5
dabs of 0.5: 0
rabs of same: -NaN
myabs of same: .5
-------------------------------------------------------------------------
I have no idea what "-NaN" means, but I know that the value returned
for an absolute value routine should not be 0.
Any ideas? Is this a bug or is it pilot error?
Peace,
--
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Greg Economides Internet: greg@zadok.tamu.edu
Texas A&M University greg@eemips.tamu.edu