On 6 Sep., 06:36, Dima Pasechnik <dimp...@gmail.com> wrote: > On Tuesday, 6 September 2011 11:08:02 UTC+8, leif wrote: > > > On 5 Sep., 17:44, Dima Pasechnik <dim...@gmail.com> wrote: > > > Presently, int()^whatever stays Pythonic, no matter it causes a loss of > > > precision, or not. > > > Not true: > > > sage: 3r^ZZ(-3) > > 0.037037037037037035 > > sage: 3r^QQ(-3) > > 1/27 > > what is "Not true"?
That currently int()^whatever stays Pythonic (w.r.t. the type of the result). > No, really, the current behaviour of int()^-k cannot be defended. > If one thinks of int()^-k as 1/int()^k, and this is, mathematically, the > usual > definition of a negative power, it must be an Integer, even if you hold that > int()^k is int; this is the way Sage division works. Of course int(n)^-k should be int(1)/int(n)^k, yielding either a Python int or float, to stay "pythonic", or, more precisely, within Python types. > (unless you want to stay Pythonic, and get int(1)/int()^k, i.e. 0 in Python > 2, which would be > even more stupid than the current conversion into float) I consider this just a Python "bug" (perhaps inherited from early bad design), since Python (now) does have explicit integer / truncating division, a // b. > Now, as int()^-k should to be Integer, so should be int()^k, too. The former shouldn't, so the latter shouldn't either. ;-) -leif -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org