summaryrefslogtreecommitdiff
path: root/rtl/inc/ufloat128.pp
blob: 28eec51f60d0064f6fa3d1df0798e7dde9a39119 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
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 float128 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 ufloat128;

  interface

    uses
      softfpu;

    type
      float128 = softfpu.float128;

    operator+ (const f1,f2 : float128) result : float128;inline;
    operator* (const f1,f2 : float128) result : float128;inline;
    operator- (const f1,f2 : float128) result : float128;inline;
    operator/ (const f1,f2 : float128) result : float128;inline;

    operator :=(const source : double) dest : float128;inline;

    operator :=(const source : float128) dest : double;inline;

    procedure DumpFloat128(const f : float128);

  implementation

    procedure DumpFloat128(const f : float128);
      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 : float128) result : float128;inline;
      begin
        result:=float128_add(f1,f2);
      end;


    operator* (const f1,f2 : float128) result : float128;inline;
      begin
        result:=float128_mul(f1,f2);
      end;


    operator- (const f1,f2 : float128) result : float128;inline;
      begin
        result:=float128_sub(f1,f2);
      end;


    operator/ (const f1,f2 : float128) result : float128;inline;
      begin
        result:=float128_div(f1,f2);
      end;


    operator :=(const source : double) dest : float128;inline;
      begin
        dest:=float64_to_float128(float64(source));
      end;


    operator :=(const source : float128) dest : double;inline;
      begin
        dest:=double(float128_to_float64(source));
      end;


end.