]> www.ginac.de Git - cln.git/blob - src/integer/bitwise/cl_I_logbitp_I.cc
2b58a56743350d89ccce8344e8bfaca1ddea06e7
[cln.git] / src / integer / bitwise / cl_I_logbitp_I.cc
1 // logbitp().
2
3 // General includes.
4 #include "cl_sysdep.h"
5
6 // Specification.
7 #include "cl_integer.h"
8
9
10 // Implementation.
11
12 #include "cl_I.h"
13 #include "cl_DS.h"
14 #include "cl_io.h"
15 #include "cl_integer_io.h"
16 #include "cl_abort.h"
17
18 cl_boolean logbitp (const cl_I& x, const cl_I& y)
19 {
20     // Methode:
21     // Falls x<0, Error.
22     // Falls x>=0: Falls x>=intDsize*Länge(y), teste Vorzeichen von y.
23     //             Sonst x=intDsize*k+i, Teste Bit i vom Worte Nr. k+1 (von oben herab).
24       if (!minusp(x)) // x>=0 ?
25         { if (fixnump(x))
26             { var uintL x_ = FN_to_L(x);
27               var uintC ylen;
28               var const uintD* yLSDptr;
29               I_to_NDS_nocopy(y, ,ylen=,yLSDptr=,cl_true, { return cl_false; } ); // DS zu y
30               if (x_ < intDsize*(uintL)ylen)
31                 // x ist ein Fixnum >=0, < intDsize*ylen
32                 { if (lspref(yLSDptr,floor(x_,intDsize)) & bit(x_%intDsize))
33                     return cl_true;
34                     else
35                     return cl_false;
36             }   }
37           // Vorzeichen von y testen
38           if (minusp(y))
39             return cl_true;
40             else
41             return cl_false;
42         }
43         else
44         // x<0
45         { fprint(cl_stderr, "logbitp: Index is negative: ");
46           fprint(cl_stderr, x);
47           fprint(cl_stderr, "\n");
48           cl_abort();
49         }
50 }