addaptic

Reference Arithmetic

lz_subtract

The difference of two numbers, left minus right.

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

Exact unless the difference has more places than the working precision, when it is rounded in the target's own rounding mode. The answer is in the left operand's base: binary 1010 minus hexadecimal 15 is binary −1011.

Examples

CallAnswer
lz_subtract( 0.3, 0.1 )0.2
lz_subtract( 100000000000000000001, 100000000000000000000 )1
lz_subtract( 0b1010, 0x15 )−1011 base 2

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_add The sum of two numbers.
  • lz_negate The number with its sign changed.
  • lzc_subtract The difference of two complex numbers, left minus right.