4 #include "base/cl_sysdep.h"
7 #include "cln/lfloat.h"
12 #include "float/lfloat/cl_LF.h"
13 #include "base/digitseq/cl_DS.h"
15 #include "base/cl_inline.h"
16 #include "float/lfloat/elem/cl_LF_minusp.cc"
20 cl_signean compare (const cl_LF& x, const cl_LF& y)
23 // x und y haben verschiedenes Vorzeichen ->
26 // x und y haben gleiches Vorzeichen ->
27 // x >=0 -> vergleiche x und y (die rechten 24 Bits)
28 // x <0 -> vergleiche y und x (die rechten 24 Bits)
29 if (!minusp_inline(y))
31 { if (!minusp_inline(x))
33 { // Vergleiche Exponenten und Mantissen:
34 { var uintE x_uexp = TheLfloat(x)->expo;
35 var uintE y_uexp = TheLfloat(y)->expo;
36 if (x_uexp < y_uexp) return signean_minus; // x<y
37 if (x_uexp > y_uexp) return signean_plus; // x>y
39 { var uintC x_len = TheLfloat(x)->len;
40 var uintC y_len = TheLfloat(y)->len;
41 var uintC len = (x_len<y_len ? x_len : y_len); // min(x_len,y_len)
42 // len Digits vergleichen:
44 compare_loop_msp(arrayMSDptr(TheLfloat(x)->data,x_len),arrayMSDptr(TheLfloat(y)->data,y_len),len);
45 if (!(erg==0)) { return erg; } // verschieden -> fertig
46 // gemeinsames Teilstück war gleich
47 if (x_len == y_len) { return signean_null; } // gleiche Länge -> fertig
50 { if (DS_test_loop(arrayMSDptr(TheLfloat(x)->data,x_len) mspop y_len,x_len-y_len,arrayLSDptr(TheLfloat(x)->data,x_len)))
51 { return signean_plus; } // x>y
53 { return signean_null; }
57 { if (DS_test_loop(arrayMSDptr(TheLfloat(y)->data,y_len) mspop x_len,y_len-x_len,arrayLSDptr(TheLfloat(y)->data,y_len)))
58 { return signean_minus; } // x<y
60 { return signean_null; }
65 { return signean_minus; } // x<y
68 { if (!minusp_inline(x))
70 { return signean_plus; } // x>y
73 { // Vergleiche Exponenten und Mantissen:
74 { var uintE x_uexp = TheLfloat(x)->expo;
75 var uintE y_uexp = TheLfloat(y)->expo;
76 if (x_uexp < y_uexp) return signean_plus; // |x|<|y| -> x>y
77 if (x_uexp > y_uexp) return signean_minus; // |x|>|y| -> x<y
79 { var uintC x_len = TheLfloat(x)->len;
80 var uintC y_len = TheLfloat(y)->len;
81 var uintC len = (x_len<y_len ? x_len : y_len); // min(x_len,y_len)
82 // len Digits vergleichen:
84 compare_loop_msp(arrayMSDptr(TheLfloat(y)->data,y_len),arrayMSDptr(TheLfloat(x)->data,x_len),len);
85 if (!(erg==0)) { return erg; } // verschieden -> fertig
86 // gemeinsames Teilstück war gleich
87 if (x_len == y_len) { return signean_null; } // gleiche Länge -> fertig
90 { if (DS_test_loop(arrayMSDptr(TheLfloat(x)->data,x_len) mspop y_len,x_len-y_len,arrayLSDptr(TheLfloat(x)->data,x_len)))
91 { return signean_minus; } // |x|>|y| -> x<y
93 { return signean_null; }
97 { if (DS_test_loop(arrayMSDptr(TheLfloat(y)->data,y_len) mspop x_len,y_len-x_len,arrayLSDptr(TheLfloat(y)->data,y_len)))
98 { return signean_plus; } // |x|<|y| -> x>y
100 { return signean_null; }