3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-12-27 14:36:35 +00:00
z3/src/api/java/BitVecNum.java
Nikolaj Bjorner 4e77984c57 enable binary string access to unsigned numerals over API #4568
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2020-07-07 18:59:20 -07:00

84 lines
1.6 KiB
Java

/**
Copyright (c) 2012-2014 Microsoft Corporation
Module Name:
BitVecNum.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3;
import java.math.BigInteger;
/**
* Bit-vector numerals
**/
public class BitVecNum extends BitVecExpr
{
/**
* Retrieve the int value.
*
* @throws Z3Exception
**/
public int getInt()
{
Native.IntPtr res = new Native.IntPtr();
if (!Native.getNumeralInt(getContext().nCtx(), getNativeObject(), res)) {
throw new Z3Exception("Numeral is not an int");
}
return res.value;
}
/**
* Retrieve the 64-bit int value.
*
* @throws Z3Exception
**/
public long getLong()
{
Native.LongPtr res = new Native.LongPtr();
if (!Native.getNumeralInt64(getContext().nCtx(), getNativeObject(), res)) {
throw new Z3Exception("Numeral is not a long");
}
return res.value;
}
/**
* Retrieve the BigInteger value.
**/
public BigInteger getBigInteger()
{
return new BigInteger(this.toString());
}
/**
* Returns a decimal string representation of the numeral.
**/
@Override
public String toString()
{
return Native.getNumeralString(getContext().nCtx(), getNativeObject());
}
/**
* Returns a binary string representation of the numeral.
**/
public String toBinaryString()
{
return Native.getNumeralBinaryString(getContext().nCtx(), getNativeObject());
}
BitVecNum(Context ctx, long obj)
{
super(ctx, obj);
}
}