Testing if a result n is an Integer, for large n.
I have a number x of size 2^160, and I perform the operation n = x*(x+1.5) and want to test if the result is an integer.
In python I would normally try, n.is_integer() or use an isinstance(), but this doesn't work in sage, I assume due to the fact sage integers are set up quite differently.
Upon scouring this site, I found someone recommend n is in ZZ, but this doesn't work (sage seems to loose accuracy at this level) Example:
n = 2^160
n in ZZ
The only (terribly inefficient) way I can get this to work is to call n.divisors() and if I get the error "AttributeError: 'sage.rings.real_mpfr.RealNumber' object has no attribute 'divisors' " I know it was indeed not an integer.
There must be a better way?