-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRatNum.java
More file actions
80 lines (71 loc) · 1.98 KB
/
RatNum.java
File metadata and controls
80 lines (71 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/**
* This file was automatically generated from RatNum.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
package com.microsoft.z3;
import java.math.BigInteger;
/**
* Rational Numerals
**/
public class RatNum extends RealExpr
{
/**
* The numerator of a rational numeral.
**/
public IntNum getNumerator() throws Z3Exception
{
return new IntNum(getContext(), Native.getNumerator(getContext().nCtx(),
getNativeObject()));
}
/**
* The denominator of a rational numeral.
**/
public IntNum getDenominator() throws Z3Exception
{
return new IntNum(getContext(), Native.getDenominator(getContext().nCtx(),
getNativeObject()));
}
/**
* Converts the numerator of the rational to a BigInteger
**/
public BigInteger getBigIntNumerator() throws Z3Exception
{
IntNum n = getNumerator();
return new BigInteger(n.toString());
}
/**
* Converts the denominator of the rational to a BigInteger
**/
public BigInteger getBigIntDenominator() throws Z3Exception
{
IntNum n = getDenominator();
return new BigInteger(n.toString());
}
/**
* Returns a string representation in decimal notation. <remarks>The result
* has at most <paramref name="precision"/> decimal places.</remarks>
**/
public String toDecimalString(int precision) throws Z3Exception
{
return Native.getNumeralDecimalString(getContext().nCtx(), getNativeObject(),
precision);
}
/**
* Returns a string representation of the numeral.
**/
public String toString()
{
try
{
return Native.getNumeralString(getContext().nCtx(), getNativeObject());
} catch (Z3Exception e)
{
return "Z3Exception: " + e.getMessage();
}
}
RatNum(Context ctx, long obj) throws Z3Exception
{
super(ctx, obj);
}
}