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"? Surely conversion into float is a loss of precision.

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. 
(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)

Now, as int()^-k should to be Integer, so should be int()^k, too.
 




>
> I'm strongly against making the result of exponentiation (of e.g. 
> Python ints) depend on the exponent's *type*; it should only depend on 
> its *value*, in this case yielding either Python ints or floats in 
> turn. 
>
> Exponentiation isn't commutative (nor associative), in contrast to 
> multiplication and addition, where a factor / summand of type Integer 
> makes the product / sum be of Sage's Integer type. 
>
>
> -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

Reply via email to