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. Harald responded with a suggestion to use Integer() (thread below) Integer(p/q) works and returns True is the rational p/q reduces to an integer otherwise it exits with error. I wanted the Integer(p/q) to return False is p/q ids not reducible to an integer. Hello, I think the function does what it should. It tests if the *type* is integer, in your case it is a rational number. You can see this with type(1/2 + 1/2) To coerce a rational number ot integers, use "Integer()" e.g. Integer(1/2) -> no coercion error Integer(1/2 + 1/2) -> type(1) -> integer Harald ----Nirmal writes Thanks for your response. I was looking for a function that returns True is the rational operand reduces to an integer and returns False otherwise. Your suggestion of using Integer() has the same issue. When the rational is not reducible to an integer it returns error. For example, Integer(1/2) returns Traceback (click to the left for traceback) ... TypeError: no conversion of this rational to integer And breaks out of my computation loop. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---