There seem to be no quick help available for operators in Xcode. So in order to see the documentation for the % operator in eg
let r = 123 % 4
we have to do "Jump to Definition" on the % operator, which will take us to the following generated interface:
/// Returns the remainder of dividing the first value by the second.
/// The result of the modulo operator (`%`) has the same sign as `lhs` and is
/// less than `rhs.magnitude`.
/// let x = 22 % 5
/// // x == 2
/// let y = 22 % -5
/// // y == 2
/// let z = -22 % -5
/// // z == -2
/// For any two integers `a` and `b`, their quotient `q`, and their remainder
/// `r`, `a == b * q + r`.
/// - Parameters:
/// - lhs: The value to divide.
/// - rhs: The value to divide `lhs` by. `rhs` must not be zero.
public static func % (lhs: Int, rhs: Int) -> Int
(I'm using an Xcode 10 beta.)
Note that it says "The result of the modulo operator (%) has …"
while The Language Reference calls it "the remainder operator" and includes the following note:
The remainder operator (%) is also known as a modulo operator in other languages. However, its behavior in Swift for negative numbers means that, strictly speaking, it’s a remainder rather than a modulo operation.
So, two questions:
Is the no-quick-help-for-operators-issue known? If not, should it be reported to Jira or as a radar?
Should I file a Jira for improving the % operator documentation by replacing "modulo" with "remainder"?
What would you suggest changing there? I've read the text over a few times and it flows fairly naturally to me. My parsing of it is that the "same method" is talking about the equation solving technique that happens in between the two parts you quoted.
Two, if you're starting a -9, then walking toward 0. Then you're left with -1 as the remainder. I haven't thought about remainders deeply recently, but it seems like a plausible interpretation of numbers fitting into negative numbers.