Unsigned integers using Java API

119 Views Asked by At

I am using the Java API of Z3 and I need to define integer variables which are natural i.e. their value cannot be negative. How can I define natural data type in z3 using java API?

1

There are 1 best solutions below

1
On

It depends on the version of Java. Pre-Java 8 you have to roll your own type, often by using larger primitives so you can represent the entire range of an unsigned value at the bit-length you require.

This (may) require doing your own two's complement math.

Java 8 has a new Unsigned Integer API, which offer a much easier way of manipulating values in a truly unsigned manner. See the API docs for Integer.