Răsfoiți Sursa

* Changed signature of frexp() to match one in Math unit, so eventually a duplicate implementation in Math can be removed. Currently this frexp() remains private to unit System.

git-svn-id: trunk@33173 -
sergei 9 ani în urmă
părinte
comite
feeb50be4f
2 a modificat fișierele cu 9 adăugiri și 12 ștergeri
  1. 2 5
      rtl/inc/cgenmath.inc
  2. 7 7
      rtl/inc/genmath.inc

+ 2 - 5
rtl/inc/cgenmath.inc

@@ -115,13 +115,10 @@
 {$define SYSTEM_HAS_FREXP}
     function c_frexp(x: double; out e: longint): double; cdecl; external 'c' name 'frexp';
 
-    function frexp(x:ValReal; out e:Integer ):ValReal; {$ifdef MATHINLINE}inline;{$endif}
-    var
-      l: longint;
+    procedure frexp(x:ValReal; out Mantissa: ValReal; out Exponent: longint); {$ifdef MATHINLINE}inline;{$endif}
     begin
       resetexcepts;
-      frexp := c_frexp(x,l);
-      e := l;
+      Mantissa := c_frexp(x,Exponent);
       checkexcepts;
     end;
 {$endif not SYSTEM_HAS_FREXP}

+ 7 - 7
rtl/inc/genmath.inc

@@ -369,25 +369,25 @@ type
 
 
 {$ifndef SYSTEM_HAS_FREXP}
-    function frexp(x:Real; out e:Integer ):Real;
+    procedure frexp(X: Real; out Mantissa: Real; out Exponent: longint);
     {*  frexp() extracts the exponent from x.  It returns an integer     *}
     {*  power of two to expnt and the significand between 0.5 and 1      *}
     {*  to y.  Thus  x = y * 2**expn.                                    *}
     begin
-      e :=0;
+      exponent:=0;
       if (abs(x)<0.5) then
        While (abs(x)<0.5) do
        begin
          x := x*2;
-         Dec(e);
+         Dec(exponent);
        end
       else
        While (abs(x)>1) do
        begin
          x := x/2;
-         Inc(e);
+         Inc(exponent);
        end;
-      frexp := x;
+      Mantissa := x;
     end;
 {$endif not SYSTEM_HAS_FREXP}
 
@@ -1004,7 +1004,7 @@ type
     { a rough value for the square root.  Then Heron's iteration      }
     { is used three times to converge to an accurate value.           }
     {*****************************************************************}
-    var e   : Integer;
+    var e   : Longint;
         w,z : Real;
     begin
        if( d <= 0.0 ) then
@@ -1018,7 +1018,7 @@ type
        begin
           w := d;
           { separate exponent and significand }
-           z := frexp( d, e );
+          frexp( d, z, e );
 
           {  approximate square root of number between 0.5 and 1  }
           {  relative error of approximation = 7.47e-3            }