Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

why sagemath says 1.0 is integer?

This is really strange. sagemath 8.9

Compare

sage: var('x')
x
sage: x=1
sage: x.is_integer()
True
sage: x=1.0
sage: x.is_integer()
True

In sympy

(base) >python
Python 3.7.3 (default, Mar 27 2019, 22:11:17)
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from sympy import *
>>> from sympy.abc import x
>>> x=1
>>> isinstance(x,int)
True
>>> x=1.0
>>> isinstance(x,int)
False
>>> isinstance(x,float)
True

Question is: Should sagemath return true for 1.0 being an integer?