Laurent, I your question you gave an example where you set A=4, after which A has the type Integer:
sage: A=4 sage: type(A) <type 'sage.rings.integer.Integer'> and it would not make very much sense to provide a method for this class to test for integrality, since every such element is an Integer by definition. I suspect that in your intended application, A will be the result of come computation resulting in a real number, and you want to test whether it is (at least approximately) integral. Here are some ideas: sage: A = 4.001 sage: A in ZZ False sage: A == round(A) False sage: A=4.0 sage: A in ZZ True sage: A == round(A) True but you have to be careful: sage: x = RR(exp(pi*sqrt(163))) sage: x-round(x) 0.000000000000000 sage: x in ZZ True sage: x = RealField(100)(exp(pi*sqrt(163))) sage: x-round(x) -2.2737367544323205947875976562e-12 sage: x in ZZ False John Cremona On Mar 15, 12:35 pm, Laurent <moky.m...@gmail.com> wrote: > > 3. > > If, in your application, it is enough to know whether the given object > > x is equal to an integer, then you could do "x in ZZ". Note that this > > property has nothing to do with the type! > > > CONCLUSION: > > > We already have four different meanings of the question "Is x an > > integer?". Since different meanings of the question require different > > answers, there is certainly not *one* single test for "bein an > > integer" in Sage. > > Well. I didn't think to that. Thanks very much for your answer. I take > the third solution :) > In my case, I just want to make the difference between numbers like pi/2 > and 90 in order to guess if the user is thinking about degrees or radian. > > Laurent -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org