}
} // namespace detail
+int32_t Term::getRealOrIntegerValueSign() const
+{
+ CVC5_API_TRY_CATCH_BEGIN;
+ CVC5_API_CHECK_NOT_NULL;
+ //////// all checks before this line
+ const Rational& r = detail::getRational(*d_node);
+ return static_cast<int32_t>(r.sgn());
+ ////////
+ CVC5_API_TRY_CATCH_END;
+}
+
bool Term::isInt32Value() const
{
CVC5_API_TRY_CATCH_BEGIN;
*/
const_iterator end() const;
+ /**
+ * Get integer or real value sign. Must be called on integer or real values,
+ * or otherwise an exception is thrown.
+ * @return 0 if this term is zero, -1 if this term is a negative real or
+ * integer value, 1 if this term is a positive real or integer value.
+ */
+ int32_t getRealOrIntegerValueSign() const;
/**
* @return true if the term is an integer value that fits within int32_t.
*/
*/
protected native String toString(long pointer);
+ /**
+ * Get integer or real value sign. Must be called on integer or real values,
+ * or otherwise an exception is thrown.
+ * @return 0 if this term is zero, -1 if this term is a negative real or
+ * integer value, 1 if this term is a positive real or integer value.
+ */
+ public int getRealOrIntegerValueSign()
+ {
+ return getRealOrIntegerValueSign(pointer);
+ }
+
+ private native int getRealOrIntegerValueSign(long pointer);
+
/**
* @return true if the term is an integer value.
*/
CVC5_JAVA_API_TRY_CATCH_END_RETURN(env, nullptr);
}
+/*
+ * Class: io_github_cvc5_api_Term
+ * Method: getRealOrIntegerValueSign
+ * Signature: (J)Z
+ */
+JNIEXPORT jint JNICALL
+Java_io_github_cvc5_api_Term_getRealOrIntegerValueSign(JNIEnv* env,
+ jobject,
+ jlong pointer)
+{
+ CVC5_JAVA_API_TRY_CATCH_BEGIN;
+ Term* current = reinterpret_cast<Term*>(pointer);
+ return static_cast<jint>(current->getRealOrIntegerValueSign());
+ CVC5_JAVA_API_TRY_CATCH_END_RETURN(env, static_cast<jint>(0));
+}
+
/*
* Class: io_github_cvc5_api_Term
* Method: isIntegerValue
bint getBooleanValue() except +
bint isStringValue() except +
wstring getStringValue() except +
+ int32_t getRealOrIntegerValueSign() except +
bint isIntegerValue() except +
string getIntegerValue() except +
bint isRealValue() except +
cdef c_wstring s = self.cterm.getStringValue()
return PyUnicode_FromWideChar(s.data(), s.size())
+ def getRealOrIntegerValueSign(self):
+ """
+ Get integer or real value sign. Must be called on integer or real values,
+ or otherwise an exception is thrown.
+
+ :return: 0 if this term is zero, -1 if this term is a negative real or
+ integer value, 1 if this term is a positive real or integer value.
+ """
+ return self.cterm.getRealOrIntegerValueSign()
+
def isIntegerValue(self):
""":return: True iff this term is an integer value."""
return self.cterm.isIntegerValue()
&& !int1.isInt64Value() && !int1.isUInt64Value()
&& int1.isIntegerValue());
ASSERT_EQ(int1.getIntegerValue(), "-18446744073709551616");
+ ASSERT_TRUE(int1.getRealOrIntegerValueSign() == -1);
ASSERT_TRUE(!int2.isInt32Value() && !int2.isUInt32Value()
&& !int2.isInt64Value() && !int2.isUInt64Value()
&& int2.isIntegerValue());
ASSERT_EQ(int6.getInt64Value(), 0);
ASSERT_EQ(int6.getUInt64Value(), 0);
ASSERT_EQ(int6.getIntegerValue(), "0");
+ ASSERT_TRUE(int6.getRealOrIntegerValueSign() == 0);
ASSERT_TRUE(int7.isInt32Value() && int7.isUInt32Value() && int7.isInt64Value()
&& int7.isUInt64Value() && int7.isIntegerValue());
ASSERT_EQ(int7.getInt32Value(), 10);
ASSERT_EQ(int7.getInt64Value(), 10);
ASSERT_EQ(int7.getUInt64Value(), 10);
ASSERT_EQ(int7.getIntegerValue(), "10");
+ ASSERT_TRUE(int7.getRealOrIntegerValueSign() == 1);
ASSERT_TRUE(!int8.isInt32Value() && int8.isUInt32Value()
&& int8.isInt64Value() && int8.isUInt64Value()
&& int8.isIntegerValue());
assertTrue(int1.isIntegerValue());
assertEquals(int1.getIntegerValue().toString(), "-18446744073709551616");
+ assertEquals(int1.getRealOrIntegerValueSign(), -1);
assertTrue(int2.isIntegerValue());
assertEquals(int2.getIntegerValue().toString(), "-18446744073709551615");
assertTrue(int3.isIntegerValue());
assertEquals(int6.getIntegerValue().intValue(), 0);
assertEquals(int6.getIntegerValue().intValue(), 0);
assertEquals(int6.getIntegerValue().toString(), "0");
+ assertEquals(int6.getRealOrIntegerValueSign(), 0);
assertTrue(int7.isIntegerValue());
assertEquals(int7.getIntegerValue().intValue(), 10);
assertEquals(int7.getIntegerValue().intValue(), 10);
assertEquals(int7.getIntegerValue().toString(), "10");
+ assertEquals(int7.getRealOrIntegerValueSign(), 1);
assertTrue(int8.isIntegerValue());
assertEquals(int8.getIntegerValue().longValue(), 4294967295L);
assertEquals(int8.getIntegerValue().toString(), "4294967295");
assert int9.getIntegerValue() == 4294967296
assert int10.getIntegerValue() == 18446744073709551615
assert int11.getIntegerValue() == 18446744073709551616
+
+ assert int1.getRealOrIntegerValueSign() == -1
+ assert int6.getRealOrIntegerValueSign() == 0
+ assert int7.getRealOrIntegerValueSign() == 1
def test_get_string(solver):