1 | initial version |
The behavior you observe is due to the floor division //
having a higher precedence than the subtraction operator -
but a lower precedence than the negative operator -
, see the table of operator precedence. Compare:
sage: a = 8^2 - 3^2; a
55
sage: b = 6^2 - 9*8; b
-36
sage: n(a/b)
-1.52777777777778
sage: a//b
-2
sage: 0 - a//b # subtraction operator
2
sage: - a//b # negative operator
1
sage: 0 + (- a//b) # different from 0 - a//b
1