lz_remainder_near
The remainder after the nearest whole quotient, ties to even.
long lz_remainder_near( CLZNumber* leftOperand, CLZNumber* rightOperand, CLZNumber* targetNumber = nullptr );
left − n × right, where n is the whole number nearest left ÷ right, a tie going to the even one. 7 ÷ 2 is 3.5, so n is 4 and the answer −1, while 5 ÷ 2 is 2.5, so n is 2 and the answer 1. The answer is exact, and never more than half the right operand in size.
Examples
| Call | Answer |
|---|---|
lz_remainder_near( 7, 2 ) | −1 |
lz_remainder_near( 5, 2 ) | 1 |
lz_remainder_near( 10, 3 ) | 1 |
lz_remainder_near( −7, 2 ) | 1 |
Each answer is what Addaptic printed for the call, at 36 places unless a setting is shown.
Returns
kNoError (0) when the answer is written. Otherwise an error code, with the answer flagged infinite or not-a-number; see Errors and flags.
See also
lz_remainderThe remainder after the truncated whole quotient, left − trunc(left ÷ right) × right.lz_moduloThe remainder after the truncated whole quotient; the same operation as lz_remainder.lz_divide_integerThe whole part of the quotient, truncated toward nought.