The behaviour for ZZ--QQ--RR decided in that other thread are taking quotients over the sub-ring ZZ. More specifically:
if a,b are in ZZ, QQ or RR then it was decided that a % b should implicitly satisfy: a == (a//b) * b + a%b and a//b in ZZ and a%b has norm smaller than b (norm as in euclidean domain, and some fix to disallow a%b < 0). If we decided instead that when a,b in QQ then the a//b should be taken in Q, that would imply a//b = a/b and a%b = 0. The difference is really which ring a//b should be required to land in. More generally, if we have a ring R and a subring S, we could introduce a function //_S and %_S such that for a,b in R then a == (a //_S b) * b + a %_S b where (a //_S b) in S and (a %_S b) has norm < |b|. I'm not sure what the requirements of R and S should be for such functions to exist. Apart from all the examples with ZZ, QQ and RR, it seems to work for e.g. R = K(x) and S = K[x] for a field K with |f1/f2| being deg f1 - deg f2. It might seem mathematically "arbitrary" to say that // defaults to //_ZZ according to the above notation, whenever a,b in RR, if the above holds for a wide variety of R and S. Best, Johan >>>> 1. Should we always have >>>> >>>> a == a//b + a%b John Cremona writes: > On 19 January 2016 at 12:37, Vincent Delecroix > <20100.delecr...@gmail.com> wrote: >> On 19/01/16 09:31, John Cremona wrote: >>> >>> On 19 January 2016 at 11:49, Vincent Delecroix >>> <20100.delecr...@gmail.com> wrote: >>>> >>>> As far as I know we do not have any specifications for //. In euclidean >>>> ring >>>> it would be natural for it to be the quotient. But in other situations? >>>> >>>> 1. Should we always have >>>> >>>> a == a//b + a%b >>>> >>>> 2. Should // always be internal? >>>> >>>> On 19/01/16 08:28, Jeroen Demeyer wrote: >>>>> >>>>> >>>>> Feature or bug? >>> >>> >>> I would say "feature" since these are field elements so division is >>> always exact, unlike ZZ(7)//ZZ(2). >>> >>>>> >>>>> sage: QQ(7) // QQ(2) >>>>> 7/2 >>>>> >>>>> I would expect >>>>> >>>>> sage: QQ(7) // QQ(2) >>>>> 3 >>> >>> >>> This would only make sense if ZZ was the only ring of which QQ was the >>> field of fractions. Similarly with rational function fields, in my >>> opinion. >>> >>> But I think that >>> >>> sage: QQ(7) % QQ(2) >>> 1 >>> >>> is definitely a bug, for the same reason! (Should be 0). >> >> >> That contradicts the proposal at >> >> https://groups.google.com/forum/#!topic/sage-devel/PfMop0nyiL0 > > You are right, it does. The trouble is that there seem to be two ways > to generalize % from ZZ to QQ or RR: I was thinking of it as the > quotient, or approximate quotient for ZZ; but the other thread sees > x%y as the integer part of x/y. > > I agree that it might be useful to have a computation with (say) 100 % pi: > > sage: 100.0 % RR(pi) > -0.530964914873380 > > (without the RR one gets as error since % is not defined for SR,SR > arguments), and it would be pretty stupid to give 0 just because a > pure mathematician says that RR is a field so the division is exact. > > So provided that the documentation is very clear, defining x%y as the > integer paert of x/y, for any subset of RR, makes sense. > > (What about CC?) > > John > >> >> >> -- >> 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 sage-devel+unsubscr...@googlegroups.com. >> To post to this group, send email to sage-devel@googlegroups.com. >> Visit this group at https://groups.google.com/group/sage-devel. >> For more options, visit https://groups.google.com/d/optout. -- -- 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 sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.