Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/functions.py
diff options
context:
space:
mode:
authorReinier Heeres <reinier@heeres.eu>2009-01-10 10:47:24 (GMT)
committer Reinier Heeres <reinier@heeres.eu>2009-01-10 10:47:24 (GMT)
commitaad50487ee6a52a66b67078724cffbbb1aed19cf (patch)
treedae1ae6b2c6e8989829bf40632072a9aec9c5892 /functions.py
parent470a508fd1c6c9ecf2bfda364ba0465577e8cc1a (diff)
Update is_int function
Diffstat (limited to 'functions.py')
-rw-r--r--functions.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/functions.py b/functions.py
index b069581..7f8a552 100644
--- a/functions.py
+++ b/functions.py
@@ -254,12 +254,14 @@ def is_int(n):
if type(n) in (types.IntType, types.LongType):
return True
+ if isinstance(n, _Rational):
+ return (n.n == 0 or n.d == 1)
+
if not isinstance(n, _Decimal):
n = _d(n)
if n is None:
return False
-
(sign, d, e) = n.normalize().as_tuple()
return e >= 0
is_int.__doc__ = ('is_int(n), determine whether n is an integer.')