]> www.ginac.de Git - cln.git/blob - src/float/sfloat/elem/cl_SF_compare.cc
Fix linking problems on some platforms caused by inline/non-inline versions
[cln.git] / src / float / sfloat / elem / cl_SF_compare.cc
1 // compare().
2
3 // General includes.
4 #include "cl_sysdep.h"
5
6 // Specification.
7 #include "cln/sfloat.h"
8
9
10 // Implementation.
11
12 #include "cl_inline.h"
13 #include "cl_SF_minusp.cc"
14
15 namespace cln {
16
17 cl_signean CL_FLATTEN compare (const cl_SF& x, const cl_SF& y)
18 {
19 // Methode:
20 // x und y haben verschiedenes Vorzeichen ->
21 //    x < 0 -> x < y
22 //    x >= 0 -> x > y
23 // x und y haben gleiches Vorzeichen ->
24 //    x >=0 -> vergleiche x und y (die rechten 24 Bits)
25 //    x <0 -> vergleiche y und x (die rechten 24 Bits)
26       if (!minusp_inline(y))
27         // y>=0
28         { if (!minusp_inline(x))
29             // y>=0, x>=0
30             { if (x.word < y.word) return signean_minus; // x<y
31               if (x.word > y.word) return signean_plus; // x>y
32               return signean_null;
33             }
34             else
35             // y>=0, x<0
36             { return signean_minus; } // x<y
37         }
38         else
39         { if (!minusp_inline(x))
40             // y<0, x>=0
41             { return signean_plus; } // x>y
42             else
43             // y<0, x<0
44             { if (x.word > y.word) return signean_minus; // |x|>|y| -> x<y
45               if (x.word < y.word) return signean_plus; // |x|<|y| -> x>y
46               return signean_null;
47             }
48         }
49 }
50
51 }  // namespace cln