On Fri, Apr 24, 2009 at 10:59 AM, nirmal <nrsax...@gmail.com> wrote: > > Thanks for all the helpful suggestions. I did not realize that > is_Integer() was deprecated.
How could you not notice? If I do is_Integer I get a big DeprecationWarning: sage: is_Integer(3) /Users/wstein/.sage/temp/D_69_91_158_76.dhcp4.washington.edu/15220/_Users_wstein__sage_init_sage_0.py:1: DeprecationWarning: Using is_Integer from the top level is deprecated since it was designed to be used by developers rather than end users. It most likely does not do what you would expect it to do. If you really need to use it, import it from the module that it is defined in. # -*- coding: utf-8 -*- True sage: Does your Sage not do that? William > > On Apr 22, 2:00 am, John Cremona <john.crem...@gmail.com> wrote: >> This is precisely why we deprecated all the is_*() functions for end-user >> use: >> >> ---------------------------------------------------------------------- >> | Sage Version 3.4.1.rc4, Release Date: 2009-04-19 | >> | Type notebook() for the GUI, and license() for information. | >> ---------------------------------------------------------------------- >> >> sage: is_Integer(3/2+1/2) >> /home/masgaj/.sage/temp/host_56_150/29373/_home_masgaj__sage_init_sage_0.py:1: >> DeprecationWarning: >> Using is_Integer from the top level is deprecated since it was >> designed to be used by developers rather than end users. >> It most likely does not do what you would expect it to do. If you >> really need to use it, import it from the module that it is defined >> in. >> # -*- coding: utf-8 -*- >> False >> >> sage: (3/2+1/2).is_integral() >> True >> >> The is_*() functions just test the type of an abject (in programming terms): >> >> sage: type(3/2+1/2) >> <type 'sage.rings.rational.Rational'> >> >> and the result of 3/2+1/2 is of type Rational. Mathematically, of >> course, the same number can be an integer and a rational (and a real >> and a complex and ...). >> >> John >> >> 2009/4/22 Robert Bradshaw <rober...@math.washington.edu>: >> >> >> >> > On Apr 21, 2009, at 10:54 PM, Craig Citro wrote: >> >> >>> 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. >> >> >> You could also use the is_integral method of rational numbers: >> >> >> sage: n = 3/2 + 1/2 >> >> sage: n.is_integral() >> >> True >> >> >> (This function also exists on Integers, so you could even use it in >> >> situations where you weren't sure if you had an honest Integer or an >> >> integer masquerading as a Rational.) >> >> > Another option is >> >> > sage: 3/2 + 1/2 in ZZ >> > True >> > sage: 3/2 + 1/3 in ZZ >> > False >> >> > - Robert > > > -- William Stein Associate Professor of Mathematics University of Washington http://wstein.org --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---