diff --git a/src/Init/Prelude.lean b/src/Init/Prelude.lean index d10bd5b622..3a73455b53 100644 --- a/src/Init/Prelude.lean +++ b/src/Init/Prelude.lean @@ -1194,7 +1194,12 @@ class HDiv (α : Type u) (β : Type v) (γ : outParam (Type w)) where /-- `a / b` computes the result of dividing `a` by `b`. The meaning of this notation is type-dependent. * For most types like `Nat`, `Int`, `Rat`, `Real`, `a / 0` is defined to be `0`. - * For `Nat` and `Int`, `a / b` rounds toward 0. + * For `Nat`, `a / b` rounds downwards. + * For `Int`, `a / b` rounds downwards if `b` is positive or upwards if `b` is negative. + It is implemented as `Int.ediv`, the unique function satisfiying + `a % b + b * (a / b) = a` and `0 ≤ a % b < natAbs b` for `b ≠ 0`. + Other rounding conventions are available using the functions + `Int.fdiv` (floor rounding) and `Int.div` (truncation rounding). * For `Float`, `a / 0` follows the IEEE 754 semantics for division, usually resulting in `inf` or `nan`. -/ hDiv : α → β → γ @@ -1206,7 +1211,8 @@ This enables the notation `a % b : γ` where `a : α`, `b : β`. class HMod (α : Type u) (β : Type v) (γ : outParam (Type w)) where /-- `a % b` computes the remainder upon dividing `a` by `b`. The meaning of this notation is type-dependent. - * For `Nat` and `Int`, `a % 0` is defined to be `a`. -/ + * For `Nat` and `Int` it satisfies `a % b + b * (a / b) = a`, + and `a % 0` is defined to be `a`. -/ hMod : α → β → γ /--