3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-06-05 21:53:23 +00:00
z3/src/api/dotnet/AlgebraicNum.cs
Nikolaj Bjorner 3d37060fa9 remove dependencies on contracts
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2018-10-20 10:24:36 -07:00

77 lines
2.1 KiB
C#

/*++
Copyright (c) 2012 Microsoft Corporation
Module Name:
AlgebraicNum.cs
Abstract:
Z3 Managed API: Algebraic Numerals
Author:
Christoph Wintersteiger (cwinter) 2012-03-20
Notes:
--*/
using System.Diagnostics;
using System;
#if !FRAMEWORK_LT_4
using System.Numerics;
#endif
namespace Microsoft.Z3
{
/// <summary>
/// Algebraic numbers
/// </summary>
public class AlgebraicNum : ArithExpr
{
/// <summary>
/// Return a upper bound for a given real algebraic number.
/// The interval isolating the number is smaller than 1/10^<paramref name="precision"/>.
/// <seealso cref="Expr.IsAlgebraicNumber"/>
/// </summary>
/// <param name="precision">the precision of the result</param>
/// <returns>A numeral Expr of sort Real</returns>
public RatNum ToUpper(uint precision)
{
return new RatNum(Context, Native.Z3_get_algebraic_number_upper(Context.nCtx, NativeObject, precision));
}
/// <summary>
/// Return a lower bound for the given real algebraic number.
/// The interval isolating the number is smaller than 1/10^<paramref name="precision"/>.
/// <seealso cref="Expr.IsAlgebraicNumber"/>
/// </summary>
/// <param name="precision"></param>
/// <returns>A numeral Expr of sort Real</returns>
public RatNum ToLower(uint precision)
{
return new RatNum(Context, Native.Z3_get_algebraic_number_lower(Context.nCtx, NativeObject, precision));
}
/// <summary>
/// Returns a string representation in decimal notation.
/// </summary>
/// <remarks>The result has at most <paramref name="precision"/> decimal places.</remarks>
public string ToDecimal(uint precision)
{
return Native.Z3_get_numeral_decimal_string(Context.nCtx, NativeObject, precision);
}
#region Internal
internal AlgebraicNum(Context ctx, IntPtr obj)
: base(ctx, obj)
{
Debug.Assert(ctx != null);
}
#endregion
}
}