Python 2.x also decided that integer division is C division, which we totally violate. So we have never kept with the Python semantics for division. Not that Python has rationals out of the box anyways. Whatever implementation we chose, people will trip over that. The only thing more confusing than having two different but completely reasonable behaviors is switching between them.
PS: yes I know the py3 changes... On Wednesday, January 20, 2016 at 12:37:42 PM UTC, William wrote: > > When lurking and reading this thread, I keep being reminded of Justin > Walker's remarks that a "principle of least surprise" can be useful in > such design decisions. In this particular case, there's two things > that argue for what Jeroen suggests: > > - If you have integers a and b, and write a//b then it's very clear > what happens. If somehow you make a or b into a rational number, then > do a//b, it would be really confusing if you get a completely > different answer. A similar issue has tripped people up with GCD, > LCM, etc., in the past. > > - // is literally called "floordiv" or "floor division" in Python. > The closest way of writing this is math.floor(a/b). > > - Python already decided what floordiv means for Python floats. It > would be natural if for Sage rationals a,b, we have float(a//b) "=" > float(a)//float(b). > > So I think either we implement what Jeroen suggests, or raise an > exception. > > -- William > > On Wed, Jan 20, 2016 at 4:28 AM, Jeroen Demeyer <[email protected] > <javascript:>> wrote: > > On 2016-01-20 12:32, Volker Braun wrote: > >> > >> Of course you can define as ZZ-floor division as the above operation in > >> QQ, but thats doesn't generalize to other rings. > > > > > > True, this doesn't work in full mathematical generality. But that's not > a > > good reason to just throw everything away. > > > > Many useful Euclidean divisions can be defined in terms of a > "floor"-like > > function on the fraction field. > > > > More precisely, we could define a *floor domain* as a domain R together > with > > a function floor: frac(R)->R such that the operation a//b, defined as > > floor(a/b) makes R into a Euclidean domain. > > > > Then ZZ is a floor domain and K[x] is also a floor-domain. Also the > > Euclidean quadratic imaginary rings like Z[I] are floor domains. > > > > > > Jeroen. > > > > > > -- > > You received this message because you are subscribed to the Google > Groups > > "sage-devel" group. > > To unsubscribe from this group and stop receiving emails from it, send > an > > email to [email protected] <javascript:>. > > To post to this group, send email to [email protected] > <javascript:>. > > Visit this group at https://groups.google.com/group/sage-devel. > > For more options, visit https://groups.google.com/d/optout. > > > > -- > William (http://wstein.org) > -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.
