On Oct 29, 2008, at 7:45 AM, Georg wrote: > Hi, > I'm using sage 3.1.3 on Debian system. > Is this a bug or a feature? > > sage: type(5. + RDF(5)); type(RDF(5) + 5.) > <type 'sage.rings.real_mpfr.RealNumber'> > <type 'sage.rings.real_double.RealDoubleElement'> > > somehow '+' ist not comutative, allthough '5. + RDF(5) == RDF(5) + 5.' > yields 'True',
RDF and RealField(35) are canonically isomorphic, so + is mathematically commutative, but not implementation-wise. If there are coercions in both directions then an arbitrary choice must be made, in this case it defaults to the one on the left. It doesn't matter too much as the result can always get coerced to the other side if needed. > and > > sage: type(RDF(pi) * 5.n(prec=53)) > <type 'sage.rings.real_double.RealDoubleElement'> > sage: type(5.n(prec=53) * RDF(pi)) > <type 'sage.rings.real_mpfr.RealNumber'> > sage: type(5.n(prec=54) * RDF(pi)) > <type 'sage.rings.real_double.RealDoubleElement'> > > especially the last one, should'nt that be coerced to a mpfr type of > 53 Bit precision or is there a rule like coerce to the type with lower > precision and if both are of same precision coerce to the first one? That is precisely the rule, as specified in the reference manual. - Robert --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-support@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-support URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---