Z3
 
Loading...
Searching...
No Matches
Public Member Functions
RatNum Class Reference
+ Inheritance diagram for RatNum:

Public Member Functions

IntNum getNumerator ()
 
IntNum getDenominator ()
 
BigInteger getBigIntNumerator ()
 
BigInteger getBigIntDenominator ()
 
long[] getSmall ()
 
long[] getRationalInt64 ()
 
String toDecimalString (int precision)
 
String toString ()
 

Detailed Description

Rational Numerals

Definition at line 25 of file RatNum.java.

Member Function Documentation

◆ getBigIntDenominator()

BigInteger getBigIntDenominator ( )
inline

Converts the denominator of the rational to a BigInteger

Definition at line 57 of file RatNum.java.

58 {
59 IntNum n = getDenominator();
60 return new BigInteger(n.toString());
61 }

◆ getBigIntNumerator()

BigInteger getBigIntNumerator ( )
inline

Converts the numerator of the rational to a BigInteger

Definition at line 48 of file RatNum.java.

49 {
50 IntNum n = getNumerator();
51 return new BigInteger(n.toString());
52 }

◆ getDenominator()

IntNum getDenominator ( )
inline

The denominator of a rational numeral.

Definition at line 39 of file RatNum.java.

40 {
41 return new IntNum(getContext(), Native.getDenominator(getContext().nCtx(),
42 getNativeObject()));
43 }

Referenced by RatNum.getBigIntDenominator().

◆ getNumerator()

IntNum getNumerator ( )
inline

The numerator of a rational numeral.

Definition at line 30 of file RatNum.java.

31 {
32 return new IntNum(getContext(), Native.getNumerator(getContext().nCtx(),
33 getNativeObject()));
34 }

Referenced by RatNum.getBigIntNumerator().

◆ getRationalInt64()

long[] getRationalInt64 ( )
inline

Retrieve the numerator and denominator as 64-bit integers. Returns null if the value does not fit in 64-bit integers.

Returns
a two-element array [numerator, denominator], or null

Definition at line 82 of file RatNum.java.

83 {
84 Native.LongPtr num = new Native.LongPtr();
85 Native.LongPtr den = new Native.LongPtr();
86 if (!Native.getNumeralRationalInt64(getContext().nCtx(), getNativeObject(), num, den))
87 return null;
88 return new long[] { num.value, den.value };
89 }

◆ getSmall()

long[] getSmall ( )
inline

Retrieve the numerator and denominator as 64-bit integers. Throws if the value does not fit in 64-bit integers.

Returns
a two-element array [numerator, denominator]

Definition at line 68 of file RatNum.java.

69 {
70 Native.LongPtr num = new Native.LongPtr();
71 Native.LongPtr den = new Native.LongPtr();
72 if (!Native.getNumeralSmall(getContext().nCtx(), getNativeObject(), num, den))
73 throw new Z3Exception("Numeral does not fit in int64");
74 return new long[] { num.value, den.value };
75 }

◆ toDecimalString()

String toDecimalString ( int  precision)
inline

Returns a string representation in decimal notation. Remarks: The result has at most precision decimal places.

Definition at line 96 of file RatNum.java.

97 {
98 return Native.getNumeralDecimalString(getContext().nCtx(), getNativeObject(),
99 precision);
100 }

◆ toString()

String toString ( )
inline

Returns a string representation of the numeral.

Definition at line 106 of file RatNum.java.

106 {
107 return Native.getNumeralString(getContext().nCtx(), getNativeObject());
108 }