]> www.ginac.de Git - cln.git/blob - src/integer/bitwise/cl_I_logbitp.cc
Finalize CLN 1.3.7 release.
[cln.git] / src / integer / bitwise / cl_I_logbitp.cc
1 // logbitp().
2
3 // General includes.
4 #include "base/cl_sysdep.h"
5
6 // Specification.
7 #include "cln/integer.h"
8
9
10 // Implementation.
11
12 #include "integer/cl_I.h"
13 #include "base/digitseq/cl_DS.h"
14
15 namespace cln {
16
17 bool logbitp (uintC x, const cl_I& y)
18 {
19     // Methode:
20     // Falls x>=intDsize*Länge(y), teste Vorzeichen von y.
21     // Sonst x=intDsize*k+i, Teste Bit i vom Worte Nr. k+1 (von oben herab).
22
23         var const uintD* yMSDptr;
24         var uintC ylen;
25         var const uintD* yLSDptr;
26         I_to_NDS_nocopy(y, yMSDptr=,ylen=,yLSDptr=,true, { return false; } ); // DS zu y
27         if (x < intDsize*ylen)
28                 // x ist >=0, < intDsize*ylen
29                 { if (lspref(yLSDptr,floor(x,intDsize)) & bit(x%intDsize))
30                     return true;
31                     else
32                     return false;
33                 }
34         // Vorzeichen von y testen
35         if (/* (ylen > 0) && */ ((sintD)mspref(yMSDptr,0) < 0))
36             return true;
37             else
38             return false;
39 }
40
41 }  // namespace cln