]> www.ginac.de Git - cln.git/blob - src/float/ffloat/elem/cl_FF_compare.cc
* All Files have been modified for inclusion of namespace cln;
[cln.git] / src / float / ffloat / elem / cl_FF_compare.cc
1 // compare().
2
3 // General includes.
4 #include "cl_sysdep.h"
5
6 // Specification.
7 #include "cln/ffloat.h"
8
9
10 // Implementation.
11
12 #include "cl_FF.h"
13
14 namespace cln {
15
16 cl_signean compare (const cl_FF& x, const cl_FF& y)
17 {
18 // Methode:
19 // x und y haben verschiedenes Vorzeichen ->
20 //    x < 0 -> x < y
21 //    x >= 0 -> x > y
22 // x und y haben gleiches Vorzeichen ->
23 //    x >=0 -> vergleiche x und y (die rechten 24 Bits)
24 //    x <0 -> vergleiche y und x (die rechten 24 Bits)
25       var uint32 x_ = cl_ffloat_value(x);
26       var uint32 y_ = cl_ffloat_value(y);
27       if ((sint32)y_ >= 0)
28         // y>=0
29         { if ((sint32)x_ >= 0)
30             // y>=0, x>=0
31             { if (x_ < y_) return signean_minus; // x<y
32               if (x_ > y_) return signean_plus; // x>y
33               return signean_null;
34             }
35             else
36             // y>=0, x<0
37             { return signean_minus; } // x<y
38         }
39         else
40         { if ((sint32)x_ >= 0)
41             // y<0, x>=0
42             { return signean_plus; } // x>y
43             else
44             // y<0, x<0
45             { if (x_ > y_) return signean_minus; // |x|>|y| -> x<y
46               if (x_ < y_) return signean_plus; // |x|<|y| -> x>y
47               return signean_null;
48             }
49         }
50 }
51
52 }  // namespace cln