sage: def f(n):
... if abs(n-n.integer_part())<1*e-10:
... return n.integer_part()
... else:
... return n
sage: n=5.0000000000000001
sage: f(n)
5.000000000000000
sage: type(f(n))
<type 'sage.rings.real_mpfr.RealLiteral'>
sage: n.integer_part()
5
sage: n.integer_part()==5
True
sage: f(n)==5
False