]> www.ginac.de Git - cln.git/blob - src/integer/bitwise/cl_I_logbitp_I.cc
Make scale_float() not throw a floating_point_underflow_exception...
[cln.git] / src / integer / bitwise / cl_I_logbitp_I.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 #include "cln/io.h"
15 #include "cln/integer_io.h"
16 #include "cln/exception.h"
17 #include <sstream>
18
19 namespace cln {
20
21 bool logbitp (const cl_I& x, const cl_I& y)
22 {
23     // Methode:
24     // Falls x<0, Error.
25     // Falls x>=0: Falls x>=intDsize*Länge(y), teste Vorzeichen von y.
26     //             Sonst x=intDsize*k+i, Teste Bit i vom Worte Nr. k+1 (von oben herab).
27       if (!minusp(x)) // x>=0 ?
28         { if (fixnump(x))
29             { var uintV x_ = FN_to_V(x);
30               var uintC ylen;
31               var const uintD* yLSDptr;
32               I_to_NDS_nocopy(y, ,ylen=,yLSDptr=,true, { return false; } ); // DS zu y
33               if (x_ < intDsize*ylen)
34                 // x ist ein Fixnum >=0, < intDsize*ylen
35                 { if (lspref(yLSDptr,floor(x_,intDsize)) & bit(x_%intDsize))
36                     return true;
37                     else
38                     return false;
39             }   }
40           // Vorzeichen von y testen
41           if (minusp(y))
42             return true;
43             else
44             return false;
45         }
46         else
47         // x<0
48         { std::ostringstream buf;
49           fprint(buf, "logbitp: Index is negative: ");
50           fprint(buf, x);
51           throw runtime_exception(buf.str());
52         }
53 }
54
55 }  // namespace cln