Z3
IntNum.cs
Go to the documentation of this file.
1 /*++
2 Copyright (c) 2012 Microsoft Corporation
3 
4 Module Name:
5 
6  IntNum.cs
7 
8 Abstract:
9 
10  Z3 Managed API: Int Numerals
11 
12 Author:
13 
14  Christoph Wintersteiger (cwinter) 2012-03-20
15 
16 Notes:
17 
18 --*/
19 using System;
21 
22 #if !FRAMEWORK_LT_4
23 using System.Numerics;
24 #endif
25 
26 namespace Microsoft.Z3
27 {
31  [ContractVerification(true)]
32  public class IntNum : IntExpr
33  {
34 
35  #region Internal
36  internal IntNum(Context ctx, IntPtr obj)
37  : base(ctx, obj)
38  {
39  Contract.Requires(ctx != null);
40  }
41  #endregion
42 
43 
47  public UInt64 UInt64
48  {
49  get
50  {
51  UInt64 res = 0;
52  if (Native.Z3_get_numeral_uint64(Context.nCtx, NativeObject, ref res) == 0)
53  throw new Z3Exception("Numeral is not a 64 bit unsigned");
54  return res;
55  }
56  }
57 
61  public int Int
62  {
63  get
64  {
65  int res = 0;
66  if (Native.Z3_get_numeral_int(Context.nCtx, NativeObject, ref res) == 0)
67  throw new Z3Exception("Numeral is not an int");
68  return res;
69  }
70  }
71 
75  public Int64 Int64
76  {
77  get
78  {
79  Int64 res = 0;
80  if (Native.Z3_get_numeral_int64(Context.nCtx, NativeObject, ref res) == 0)
81  throw new Z3Exception("Numeral is not an int64");
82  return res;
83  }
84  }
85 
89  public uint UInt
90  {
91  get
92  {
93  uint res = 0;
94  if (Native.Z3_get_numeral_uint(Context.nCtx, NativeObject, ref res) == 0)
95  throw new Z3Exception("Numeral is not a uint");
96  return res;
97  }
98  }
99 
100 #if !FRAMEWORK_LT_4
101  public BigInteger BigInteger
105  {
106  get
107  {
108  return BigInteger.Parse(this.ToString());
109  }
110  }
111 #endif
112 
116  public override string ToString()
117  {
118  return Native.Z3_get_numeral_string(Context.nCtx, NativeObject);
119  }
120  }
121 }
override string ToString()
Returns a string representation of the numeral.
Definition: IntNum.cs:116
def Int(name, ctx=None)
Definition: z3py.py:2808
Integer Numerals
Definition: IntNum.cs:32
The main interaction with Z3 happens via the Context.
Definition: Context.cs:32
The exception base class for error reporting from Z3
Definition: Z3Exception.cs:30
Int expressions
Definition: IntExpr.cs:31