addaptic

Reference Arithmetic

lz_remainder

The remainder after the truncated whole quotient, left − trunc(left ÷ right) × right.

long lz_remainder( CLZNumber* leftOperand, CLZNumber* rightOperand, CLZNumber* targetNumber = nullptr );

The whole quotient is truncated toward nought, so the answer has the left operand's sign. It is exact and keeps every place it has. lz_remainder and lz_modulo are the same operation under two names; lz_remainder_near takes the nearest whole quotient instead.

Examples

CallAnswer
lz_remainder( 7, 2 )1
lz_remainder( −7, 2 )−1
lz_remainder( 1, 0.3 )0.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_modulo The remainder after the truncated whole quotient; the same operation as lz_remainder.
  • lz_remainder_near The remainder after the nearest whole quotient, ties to even.
  • lz_divide_integer The whole part of the quotient, truncated toward nought.