From ff809db16d1f483efd32c234e0f22f4f14786192 Mon Sep 17 00:00:00 2001
From: Leonardo de Moura <leonardo@microsoft.com>
Date: Tue, 8 Jan 2013 15:40:19 -0800
Subject: [PATCH] Add get_int and get_uint to mpz_manager

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
---
 src/util/mpz.h | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/util/mpz.h b/src/util/mpz.h
index c7c1a880f..3582f0ad1 100644
--- a/src/util/mpz.h
+++ b/src/util/mpz.h
@@ -676,6 +676,14 @@ public:
 
     int64 get_int64(mpz const & a) const;
 
+    bool is_uint(mpz const & a) const { return is_uint64(a) && get_uint64(a) < UINT_MAX; }
+    
+    unsigned get_uint(mpz const & a) const { SASSERT(is_uint(a)); return static_cast<unsigned>(get_uint64(a)); }
+
+    bool is_int(mpz const & a) const { return is_int64(a) && INT_MIN < get_int64(a) && get_int64(a) < INT_MAX; }
+    
+    int get_int(mpz const & a) const { SASSERT(is_int(a)); return static_cast<int>(get_int64(a)); }
+
     double get_double(mpz const & a) const;
 
     std::string to_string(mpz const & a) const;