3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-29 11:55:51 +00:00

Managed API: Refactoring and formatting.

Signed-off-by: Christoph M. Wintersteiger <cwinter@microsoft.com>
This commit is contained in:
Christoph M. Wintersteiger 2012-11-23 18:30:51 +00:00
parent edc9dccbcf
commit 7defd469bb
52 changed files with 2006 additions and 1657 deletions

111
src/api/dotnet/RatNum.cs Normal file
View file

@ -0,0 +1,111 @@
/*++
Copyright (c) 2012 Microsoft Corporation
Module Name:
IntNum.cs
Abstract:
Z3 Managed API: Int Numerals
Author:
Christoph Wintersteiger (cwinter) 2012-03-20
Notes:
--*/
using System;
using System.Diagnostics.Contracts;
#if !FRAMEWORK_LT_4
using System.Numerics;
#endif
namespace Microsoft.Z3
{
/// <summary>
/// Rational Numerals
/// </summary>
[ContractVerification(true)]
public class RatNum : RealExpr
{
/// <summary>
/// The numerator of a rational numeral.
/// </summary>
public IntNum Numerator
{
get
{
Contract.Ensures(Contract.Result<IntNum>() != null);
return new IntNum(Context, Native.Z3_get_numerator(Context.nCtx, NativeObject));
}
}
/// <summary>
/// The denominator of a rational numeral.
/// </summary>
public IntNum Denominator
{
get
{
Contract.Ensures(Contract.Result<IntNum>() != null);
return new IntNum(Context, Native.Z3_get_denominator(Context.nCtx, NativeObject));
}
}
#if !FRAMEWORK_LT_4
/// <summary>
/// Converts the numerator of the rational to a BigInteger
/// </summary>
public BigInteger BigIntNumerator
{
get
{
IntNum n = Numerator;
return BigInteger.Parse(n.ToString());
}
}
/// <summary>
/// Converts the denominator of the rational to a BigInteger
/// </summary>
public BigInteger BigIntDenominator
{
get
{
IntNum n = Denominator;
return BigInteger.Parse(n.ToString());
}
}
#endif
/// <summary>
/// Returns a string representation in decimal notation.
/// </summary>
/// <remarks>The result has at most <paramref name="precision"/> decimal places.</remarks>
public string ToDecimalString(uint precision)
{
return Native.Z3_get_numeral_decimal_string(Context.nCtx, NativeObject, precision);
}
/// <summary>
/// Returns a string representation of the numeral.
/// </summary>
public override string ToString()
{
return Native.Z3_get_numeral_string(Context.nCtx, NativeObject);
}
#region Internal
internal RatNum(Context ctx, IntPtr obj)
: base(ctx, obj)
{
Contract.Requires(ctx != null);
}
#endregion
}
}