On Monday, 5 September 2011 22:41:50 UTC+8, rjf wrote:
>
> is 4^(-2)  (use various kinds of integers)  integer rational float? 
> ditto for 
>   5^(-2) ? 
>
> Seems to me that the presence of python integers is an inconsistency 
> waiting to appear, 


as brilliantly uncovered by our 2nd year undergrads :)

With the patch I propose one has
sage: type(int(5)^-2)         
<type 'sage.rings.rational.Rational'>
sage: type(int(5)^int(-2))
<type 'float'>

with the idea that if you want to stay Pythonic, you can (the 2nd example), 
but otherwise you get promoted to the better situation (the 1st example), 
when everything is exact.
Presently, int()^whatever stays Pythonic, no matter it causes a loss of 
precision, or not.
One gets bizzare things like:

sage: def f(x): return x^-3
....: 
sage: f(int(3))
0.037037037037037035
sage: var('x')
x
sage: p(x)=x^-3
sage: p(int(3))
1/27

i.e. symbolic functions and the procedures behave drastically differently, 
etc...

Certain purists argue that I am wrong, and that the loss of precision must 
be preferred...

 

> and 
> the only proper use of python ints is as a sage integer which happens 
> to be, at the moment, 
> small in magnitude. 
>   Lisp does this right, with fixnums automatically promoted to bignums 
> if they get too big. 
> Coercion from rational to integer happens if the rational has a 
> denominator of 1. 
>  There are lots more of these, e.g complex with imag part zero etc. 
> Do you want 
> these all to be equal.... 
> 1+0*i,  1/1, 1, int(1)?   1.0 1.0d0?  maybe. 
> RJF 
>
> On Sep 5, 6:52 am, Dima Pasechnik <dim...@gmail.com> wrote: 
> > this is now #11779

-- 
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