Open mahrud opened 2 weeks ago
I think they're correct. My understanding is that //
and %
give the quotient and remainder from division in a Euclidean domain, and fields are trivially Euclidean domains since $x = y(xy^{-1}) + 0$ for nonzero $y$.
But that's just /
division in fields, whereas //
and %
also work on domains.
I should have also included an example from python for contrast:
>>> 13.3 // 4.0
3.0
>>> 13.3 % 4.0
1.3000000000000007
>>> 13.3 // 4
3.0
>>> 13.3 % 4
1.3000000000000007
>>> 13.3 // (4/1)
3.0
>>> 13.3 % (4/1)
1.3000000000000007
I think this makes more sense, both mathematically and in terms of what is actually useful. Currently computing the non-zero value of 13.3 % 4
in Macaulay2 takes several steps:
i13 : 13.3 - 4 * floor(13.3 // 4)
o13 = 1.3
Ok, I think I'm convinced that it's wrong, too. :)
Here's an article with a few different possibilities for how //
and %
might be defined over the reals: Boute, The Euclidean Definition of the Functions div and mod.
Unless I'm way off about what we want
//
and%
to mean, I think these are all wrong: https://github.com/Macaulay2/M2/blob/ec9e9ac60ed4a8e791448942202f077a88a87e15/M2/Macaulay2/m2/reals.m2#L213-L226Some examples: (afterprints are silenced)
What's the point of having
//
be a synonym for/
, and why even define%
for non-integers if the answer is always zero anyway?!