-
-
Notifications
You must be signed in to change notification settings - Fork 703
Closed
Description
> That said, William, is there a reason why this doesn't work? This is
> > what is necessitating the two type conversions above.
> >
> > sage: Integer(float(2))
> >
> > ---------------------------------------------------------------------------
> > <type 'exceptions.TypeError'> Traceback (most recent call last)
> >
> > /home/grout/<ipython console> in <module>()
> >
> > /home/grout/integer.pyx in sage.rings.integer.Integer.__init__()
> >
> > <type 'exceptions.TypeError'>: unable to coerce element to an integer
> >
> >
> > sage: Integer(RDF(2))
> >
> > ---------------------------------------------------------------------------
> > <type 'exceptions.TypeError'> Traceback (most recent call last)
> >
> > /home/grout/<ipython console> in <module>()
> >
> > /home/grout/integer.pyx in sage.rings.integer.Integer.__init__()
> >
> > <type 'exceptions.TypeError'>: unable to coerce element to an integer
> >
> >
> > I guess I would think it was a design decision to not convert floating
> > points to ints automatically. However, the following does work:
> >
> > sage: Integer(RR(2))
> > 2
> >
> >
> > This seems inconsistent.
Yep. I think it's just a NotImplementedError. Please implement it
and post a patch. Make sure that it only succeeds if
Integer(k(a)) == a
and otherwise fails. I.e., Integer(k(a)) should *not* truncate k(a).
William
Component: coercion
Keywords: editor_mhansen
Issue created by migration from https://trac.sagemath.org/ticket/2898