pow operator miscalculation

Irfan Fazel fazeli at cpsc.ucalgary.ca
Thu Sep 6 23:57:22 CEST 2001


While using GPC (both an older version and a more current version, info at 
bottom) the results of using the pow operator were not always correct (as 
shown in the typescript, results were same regardless of system).

System #1

> uname -a
SunOS csd 5.7 Generic_106541-15 sun4u sparc SUNW,Ultra-2
> gpc -v
Reading specs from
/usr/local/lang/lib/gcc-lib/sparc-sun-solaris2.7/2.8.1/specs
gpc version 19990118, based on gcc-2.8.1

System #2

> uname -a
SunOS cse 5.8 Generic_108528-10 sun4u sparc SUNW,Ultra-2
> gpc -v
Reading specs from
/usr/local/lib/gcc-lib/sparc-sun-solaris2.8/2.95.3/specs
gpc version 20010623, based on 2.95.3 20010315 (release)

Thanks,
Fazel

P.S.   I apologize in the event that this this infact is not an error or I
have emailed the wrong party.
-------------- next part --------------
Script started on Thu Sep 06 15:45:52 2001
Thu Sep  6 15:45:52 MDT 2001

%cat powTest.p


program powTest(input, output);



begin



   writeln(-2 pow 0);            (* should be 1 *)

   writeln(-2 pow 1);

   writeln(-2 pow 2); writeln;   (* should be 4 *)

   

   writeln(-1 pow 0);            (* should be 1 *)

   writeln(-1 pow 1);

   writeln(-1 pow 2); writeln;   (* should be 1 *)



   writeln(1 pow 0);

   writeln(1 pow 1);

   writeln(1 pow 2); writeln;



   writeln(2 pow 0);

   writeln(2 pow 1);

   writeln(2 pow 2); writeln;

end.

%gpc powTest.p


%./a.out


-1

-2

-4



-1

-1

-1



1

1

1



1

2

4



%exit


exit


script done on Thu Sep 06 15:46:14 2001


More information about the Gpc mailing list