addaptic

Reference Arithmetic

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

CallAnswerReturns
lz_divide( 1, 3 )0.33333333333333333333333333333333333333kNoError
lz_divide( 10, 3 )3.3333333333333333333333333333333333333kNoError
lz_divide( 1, 3 ) base 120.4 base 12kNoError
lz_divide( 22, 7 ) 50 places3.142857142857142857142857142857142857142857142857143kNoError
lz_divide( 1, 0 )infinitekDivideByZero
lz_divide( 1, 7, 10 )0.142857142857kNoError

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_integer The whole part of the quotient, truncated toward nought.
  • lz_reciprocal One over the number.
  • lz_remainder The remainder after the truncated whole quotient, left − trunc(left ÷ right) × right.
  • lzc_divide The quotient of two complex numbers, left over right.