On Thu, Nov 27, 2008 at 12:30 PM, mabshoff <[EMAIL PROTECTED]> wrote: > > > > On Nov 27, 11:24 am, Jason Grout <[EMAIL PROTECTED]> wrote: >> Ronan Paixão wrote: >> > I just found a problem with Integer(). It doesn't seem to work fine with >> > float strings. >> > Those work fine: >> > Integer("1") >> > Integer(1.) >> >> > But this doesn't: >> > Integer("1.") >> >> More data: >> >> Integer(RR('1.')) works >> Integer(RR('1.0')) works >> >> Integer('1.0') doesn't work >> >> I think that at least '1.' ought to be converted to an integer. > > Seems like a reasonable request. I would even allow ("$FOO.0"). Care > to open a ticket?
I strongly disagree, since pure Python does not allow this, and Sage's string conversion of integers should be consistent with that: sage: int('1.0') --------------------------------------------------------------------------- ValueError Traceback (most recent call last) /home/was/build/sage-3.2.1.alpha1/<ipython console> in <module>() ValueError: invalid literal for int() with base 10: '1.0' sage: int('1.') --------------------------------------------------------------------------- ValueError Traceback (most recent call last) /home/was/build/sage-3.2.1.alpha1/<ipython console> in <module>() ValueError: invalid literal for int() with base 10: '1.' sage: Moreover, Sage integers don't allow coercion from float: sage: Integer(float(1)) --------------------------------------------------------------------------- TypeError Traceback (most recent call last) /home/was/build/sage-3.2.1.alpha1/<ipython console> in <module>() /home/was/build/sage-3.2.1.alpha1/local/lib/python2.5/site-packages/sage/rings/integer.so in sage.rings.integer.Integer.__init__ (sage/rings/integer.c:6054)() TypeError: unable to coerce <type 'float'> to an integer -- William --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-devel@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sage-devel URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---