]> www.ginac.de Git - cln.git/blob - src/float/dfloat/elem/cl_DF_minus.cc
ba4bd55e259b800eebbf8a7410f99073130a6dfa
[cln.git] / src / float / dfloat / elem / cl_DF_minus.cc
1 // binary operator -
2
3 // General includes.
4 #include "cl_sysdep.h"
5
6 // Specification.
7 #include "cln/dfloat.h"
8
9
10 // Implementation.
11
12 #include "cl_DF.h"
13 #include "cl_ieee.h"
14
15 namespace cln {
16
17 NEED_IEEE_FLOATS()
18
19 const cl_DF operator- (const cl_DF& x1, const cl_DF& x2)
20 {
21 // Methode:
22 // (- x1 x2) = (+ x1 (- x2))
23 #ifdef FAST_DOUBLE
24       double_to_DF(DF_to_double(x1) - DF_to_double(x2), return ,
25                    TRUE, TRUE, // Overflow und subnormale Zahl abfangen
26                    FALSE, // kein Underflow mit Ergebnis +/- 0.0 möglich
27                           // (nach Definition der subnormalen Zahlen)
28                    FALSE, FALSE // keine Singularität, kein NaN als Ergebnis möglich
29                   );
30 #else
31 #if (cl_word_size==64)
32       var dfloat x2_ = TheDfloat(x2)->dfloat_value;
33       if (DF_uexp(x2_) == 0)
34         { return x1; }
35         else
36         { return x1 + allocate_dfloat(x2_ ^ bit(63)); }
37 #else
38       var uint32 x2_semhi = TheDfloat(x2)->dfloat_value.semhi;
39       var uint32 x2_mlo = TheDfloat(x2)->dfloat_value.mlo;
40       if (DF_uexp(x2_semhi) == 0)
41         { return x1; }
42         else
43         { return x1 + allocate_dfloat(x2_semhi ^ bit(31), x2_mlo); }
44 #endif
45 #endif
46 }
47
48 }  // namespace cln