On Apr 21, 2009, at 10:54 PM, Craig Citro wrote: >> In module sage.rings.integer >> >> is_Integer(3/2+1/2) >> >> returns >> >> False The expected output should be True as 3/2+1/2 = 2. >> >> I was planning to use this function to check if the result of >> division >> is a whole number. >> > > You could also use the is_integral method of rational numbers: > > sage: n = 3/2 + 1/2 > sage: n.is_integral() > True > > (This function also exists on Integers, so you could even use it in > situations where you weren't sure if you had an honest Integer or an > integer masquerading as a Rational.)
Another option is sage: 3/2 + 1/2 in ZZ True sage: 3/2 + 1/3 in ZZ False - Robert --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-devel@googlegroups.com To unsubscribe from this group, send email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---