unsigned int Integer::s_fastUnsignedIntMax = (1<<29)-1;
unsigned long Integer::s_slowUnsignedIntMax = (unsigned long) std::numeric_limits<unsigned int>::max();
+unsigned long Integer::s_signedLongMin = std::numeric_limits<signed long>::min();
+unsigned long Integer::s_signedLongMax = std::numeric_limits<signed long>::max();
+unsigned long Integer::s_unsignedLongMax = std::numeric_limits<unsigned long>::max();
+
Integer Integer::oneExtend(uint32_t size, uint32_t amount) const {
DebugCheckArgument((*this) < Integer(1).multiplyByPow2(size), size);
cln::cl_byte range(amount, size);
return cln::cl_I_to_uint(d_value);
}
+bool Integer::fitsSignedLong() const {
+ return d_value <= s_signedLongMax && d_value >= s_signedLongMin;
+}
+
+bool Integer::fitsUnsignedLong() const {
+ return sgn() >= 0 && d_value <= s_unsignedLongMax;
+}
+
} /* namespace CVC4 */
static signed long s_slowSignedIntMax; /* std::numeric_limits<signed int>::max() */
static signed long s_slowSignedIntMin; /* std::numeric_limits<signed int>::min() */
static unsigned long s_slowUnsignedIntMax; /* std::numeric_limits<unsigned int>::max() */
-
+ static unsigned long s_signedLongMin;
+ static unsigned long s_signedLongMax;
+ static unsigned long s_unsignedLongMax;
public:
/** Constructs a rational with the value 0. */
unsigned int getUnsignedInt() const;
+ bool fitsSignedLong() const;
+
+ bool fitsUnsignedLong() const;
+
long getLong() const {
// ensure there isn't overflow
CheckArgument(d_value <= std::numeric_limits<long>::max(), this,
return (unsigned int) d_value.get_ui();
}
+bool Integer::fitsSignedLong() const {
+ return d_value.fits_slong_p();
+}
+
+bool Integer::fitsUnsignedLong() const {
+ return d_value.fits_ulong_p();
+}
+
Integer Integer::oneExtend(uint32_t size, uint32_t amount) const {
// check that the size is accurate
DebugCheckArgument((*this) < Integer(1).multiplyByPow2(size), size);
unsigned int getUnsignedInt() const;
+ bool fitsSignedLong() const;
+
+ bool fitsUnsignedLong() const;
+
long getLong() const {
long si = d_value.get_si();
// ensure there wasn't overflow