소스 검색

Add ufloatx80 unit, to add operator overload for 80-bit extended type on CPUs that do not support this type natively

git-svn-id: trunk@37256 -
pierre 7 년 전
부모
커밋
856b3d86ce
2개의 변경된 파일92개의 추가작업 그리고 0개의 파일을 삭제
  1. 1 0
      .gitattributes
  2. 91 0
      rtl/inc/ufloatx80.pp

+ 1 - 0
.gitattributes

@@ -9295,6 +9295,7 @@ rtl/inc/typefile.inc svneol=native#text/plain
 rtl/inc/typshrd.inc svneol=native#text/plain
 rtl/inc/typshrdh.inc svneol=native#text/plain
 rtl/inc/ufloat128.pp svneol=native#text/plain
+rtl/inc/ufloatx80.pp svneol=native#text/plain
 rtl/inc/ustringh.inc svneol=native#text/plain
 rtl/inc/ustrings.inc svneol=native#text/plain
 rtl/inc/uuchar.pp svneol=native#text/plain

+ 91 - 0
rtl/inc/ufloatx80.pp

@@ -0,0 +1,91 @@
+{
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 2007 by the FPC development time
+
+    Implements overloaded operators and misc. functions to
+    provide a floatx80 type
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+{$inline on}
+unit ufloatx80;
+
+  interface
+
+    uses
+      sfpux80;
+
+    type
+      floatx80 = sfpux80.floatx80;
+
+    operator+ (const f1,f2 : floatx80) result : floatx80;inline;
+    operator* (const f1,f2 : floatx80) result : floatx80;inline;
+    operator- (const f1,f2 : floatx80) result : floatx80;inline;
+    operator/ (const f1,f2 : floatx80) result : floatx80;inline;
+
+    operator :=(const source : double) dest : floatx80;inline;
+
+    operator :=(const source : floatx80) dest : double;inline;
+
+    procedure DumpFloatx80(const f : floatx80);
+
+  implementation
+
+    procedure DumpFloatx80(const f : floatx80);
+      type
+        ta = packed array[0..15] of byte;
+      var
+        i : longint;
+      begin
+        for i:=15 downto 0 do
+          begin
+            write(hexstr(ta(f)[i],2));
+            if i<15 then
+              write(' ');
+          end;
+      end;
+
+
+    operator+ (const f1,f2 : floatx80) result : floatx80;inline;
+      begin
+        result:=floatx80_add(f1,f2);
+      end;
+
+
+    operator* (const f1,f2 : floatx80) result : floatx80;inline;
+      begin
+        result:=floatx80_mul(f1,f2);
+      end;
+
+
+    operator- (const f1,f2 : floatx80) result : floatx80;inline;
+      begin
+        result:=floatx80_sub(f1,f2);
+      end;
+
+
+    operator/ (const f1,f2 : floatx80) result : floatx80;inline;
+      begin
+        result:=floatx80_div(f1,f2);
+      end;
+
+
+    operator :=(const source : double) dest : floatx80;inline;
+      begin
+        dest:=float64_to_floatx80(float64(source));
+      end;
+
+
+    operator :=(const source : floatx80) dest : double;inline;
+      begin
+        dest:=double(floatx80_to_float64(source));
+      end;
+
+
+end.