7 #include "cln/lfloat.h"
16 #define MAYBE_INLINE inline
17 #include "cl_LF_minusp.cc"
21 cl_signean compare (const cl_LF& x, const cl_LF& y)
24 // x und y haben verschiedenes Vorzeichen ->
27 // x und y haben gleiches Vorzeichen ->
28 // x >=0 -> vergleiche x und y (die rechten 24 Bits)
29 // x <0 -> vergleiche y und x (die rechten 24 Bits)
34 { // Vergleiche Exponenten und Mantissen:
35 { var uintL x_uexp = TheLfloat(x)->expo;
36 var uintL y_uexp = TheLfloat(y)->expo;
37 if (x_uexp < y_uexp) return signean_minus; // x<y
38 if (x_uexp > y_uexp) return signean_plus; // x>y
40 { var uintC x_len = TheLfloat(x)->len;
41 var uintC y_len = TheLfloat(y)->len;
42 var uintC len = (x_len<y_len ? x_len : y_len); // min(x_len,y_len)
43 // len Digits vergleichen:
45 compare_loop_msp(arrayMSDptr(TheLfloat(x)->data,x_len),arrayMSDptr(TheLfloat(y)->data,y_len),len);
46 if (!(erg==0)) { return erg; } // verschieden -> fertig
47 // gemeinsames Teilstück war gleich
48 if (x_len == y_len) { return signean_null; } // gleiche Länge -> fertig
51 { if (DS_test_loop(arrayMSDptr(TheLfloat(x)->data,x_len) mspop y_len,x_len-y_len,arrayLSDptr(TheLfloat(x)->data,x_len)))
52 { return signean_plus; } // x>y
54 { return signean_null; }
58 { if (DS_test_loop(arrayMSDptr(TheLfloat(y)->data,y_len) mspop x_len,y_len-x_len,arrayLSDptr(TheLfloat(y)->data,y_len)))
59 { return signean_minus; } // x<y
61 { return signean_null; }
66 { return signean_minus; } // x<y
71 { return signean_plus; } // x>y
74 { // Vergleiche Exponenten und Mantissen:
75 { var uintL x_uexp = TheLfloat(x)->expo;
76 var uintL y_uexp = TheLfloat(y)->expo;
77 if (x_uexp < y_uexp) return signean_plus; // |x|<|y| -> x>y
78 if (x_uexp > y_uexp) return signean_minus; // |x|>|y| -> x<y
80 { var uintC x_len = TheLfloat(x)->len;
81 var uintC y_len = TheLfloat(y)->len;
82 var uintC len = (x_len<y_len ? x_len : y_len); // min(x_len,y_len)
83 // len Digits vergleichen:
85 compare_loop_msp(arrayMSDptr(TheLfloat(y)->data,y_len),arrayMSDptr(TheLfloat(x)->data,x_len),len);
86 if (!(erg==0)) { return erg; } // verschieden -> fertig
87 // gemeinsames Teilstück war gleich
88 if (x_len == y_len) { return signean_null; } // gleiche Länge -> fertig
91 { if (DS_test_loop(arrayMSDptr(TheLfloat(x)->data,x_len) mspop y_len,x_len-y_len,arrayLSDptr(TheLfloat(x)->data,x_len)))
92 { return signean_minus; } // |x|>|y| -> x<y
94 { return signean_null; }
98 { if (DS_test_loop(arrayMSDptr(TheLfloat(y)->data,y_len) mspop x_len,y_len-x_len,arrayLSDptr(TheLfloat(y)->data,y_len)))
99 { return signean_plus; } // |x|<|y| -> x>y
101 { return signean_null; }