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