lz_divide
The quotient of two numbers, left over right.
long lz_divide( CLZNumber* leftOperand, CLZNumber* rightOperand, CLZNumber* targetNumber = nullptr );
long lz_divide( CLZNumber* leftOperand, CLZNumber* rightOperand, long precision );
A division by nought returns kDivideByZero and flags the answer infinite.
A quotient that does not end is written a little past the working precision, correctly rounded there. One of one or more keeps one more place, and one below one keeps two more significant digits than the precision has places, so 1 ÷ 3 at the default 36 places has 38 threes. Use lz_reciprocal for one over a number rounded to the precision itself.
The second form divides to a precision given for this call, in place of the working precision, and writes the quotient into the left operand.
Examples
| Call | Answer | Returns |
|---|---|---|
lz_divide( 1, 3 ) | 0.33333333333333333333333333333333333333 | kNoError |
lz_divide( 10, 3 ) | 3.3333333333333333333333333333333333333 | kNoError |
lz_divide( 1, 3 ) base 12 | 0.4 base 12 | kNoError |
lz_divide( 22, 7 ) 50 places | 3.142857142857142857142857142857142857142857142857143 | kNoError |
lz_divide( 1, 0 ) | infinite | kDivideByZero |
lz_divide( 1, 7, 10 ) | 0.142857142857 | kNoError |
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_divide_integerThe whole part of the quotient, truncated toward nought.lz_reciprocalOne over the number.lz_remainderThe remainder after the truncated whole quotient, left − trunc(left ÷ right) × right.lzc_divideThe quotient of two complex numbers, left over right.