On Tue, 2003-11-25 at 13:25, Florian Klaempfl wrote:

> Which checks do you mean exactly?

Actually there are two things.
I originally thought it would be better to just let the FPU execute the
instructions and then catch the signal/exception/whatever after the
fact.

> I guess the poster meant that e.g. (-3)^2 is possible in inside real
> numbers however the default forumula exp(2*ln(-3)) faults on it.

And thats the other. And I'm an idiot for writing a patch that won't
work. Apologies for that. Attached is a patch that really fixes the
issue and does that by checking the arguments and doing a transformed
calculation.

johannes
-- 
http://www.sipsolutions.de/
GnuPG key: http://www.sipsolutions.de/keys/JohannesBerg.asc
  Key-ID: 9AB78CA5 Johannes Berg <[EMAIL PROTECTED]>
  Fingerprint = AD02 0176 4E29 C137 1DF6 08D2 FC44 CF86 9AB7 8CA5
Index: i386/math.inc
===================================================================
RCS file: /FPC/CVS/fpc/rtl/i386/math.inc,v
retrieving revision 1.17
diff -u -r1.17 math.inc
--- i386/math.inc	24 Nov 2003 21:57:43 -0000	1.17
+++ i386/math.inc	26 Nov 2003 21:47:52 -0000
@@ -189,12 +189,17 @@
               HandleError(207);
           end
         else if expo=0 then
-         power:=1
+          power:=1
         else
         { bas < 0 is not allowed when doing roots }
-         if (bas<0) and (frac(expo) <> 0) then
-          handleerror(207)
-         else
+         if (bas<0) then begin
+           if frac(expo) = 0 then begin
+             power := exp(ln(abs(bas))*expo);
+             if trunc(expo) mod 2 <> 0 then 
+               power := - power;
+           end else 
+             handleerror(207)
+         end else
           power:=exp(ln(bas)*expo);
      end;
 

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to