On Sep 5, 9:31 am, Robert Bradshaw <rober...@math.washington.edu> wrote: > On Mon, Sep 5, 2011 at 7:41 AM, rjf <fate...@gmail.com> 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, 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. > > Umm... Python ints do this too. Does that mean Python gets it right?
In that case, I think it does get it right. I was under the (apparently mistaken) impression from the given example, that it got something wrong. > > What Python is missing is a rational type, so 5^(-2) is either > truncated or approximated in floating point. Ah. So it does get it wrong. (It can be argued that > rationals are not what one wants--computing with rationals can easily > become atrociously expensive.) And so it is preferable to give a mathematically wrong answer to spend the time to do it right? > > Anyway, +1 to fixing this. > > > 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. > > Yes. We have a clear rule about this in Sage as delineated in the > coercion manual. There is a whole manual on coercion? I looked at section 4.7.1 Unless one is (minimally) schooled in modern algebra and python, it's not going to make sense. e.g, will a+b*i divided by c+d*i return a ratio of complex numbers? or a complex number over a fraction field? If a,b,c are integers, but d is a float, what then? One relatively clean resolution of some of the problems is to replace every float -- on input -- to an equivalent rational. Convert rational to float only when explicitly demanded. Another model is to do something like what Mathematica does. I do not recommend it. RJF > > > > > > > > > On Sep 5, 6:52 am, Dima Pasechnik <dimp...@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 > > athttp://groups.google.com/group/sage-devel > > URL:http://www.sagemath.org -- 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