Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Added is_integer() function to complex_double.pyx
Browse files Browse the repository at this point in the history
  • Loading branch information
3shv committed Feb 13, 2014
1 parent 23a67be commit 9ed3084
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/sage/rings/complex_double.pyx
Expand Up @@ -97,6 +97,7 @@ import real_mpfr
RR = real_mpfr.RealField()

from real_double import RealDoubleElement, RDF
from sage.rings.integer_ring import ZZ


from sage.structure.parent_gens import ParentWithGens
Expand Down Expand Up @@ -1432,6 +1433,22 @@ cdef class ComplexDoubleElement(FieldElement):
"""
return True

def is_integer(self):
"""
Returns True if this number is a integer
EXAMPLES::
sage: CDF(0.5).is_integer()
False
sage: CDF(I).is_integer()
False
sage: CDF(2).is_integer()
True
"""
return (self.real() in ZZ) and (self.imag()==0)


def _pow_(self, ComplexDoubleElement a):
"""
The function returns the complex number `z` raised to the
Expand Down

0 comments on commit 9ed3084

Please sign in to comment.