addaptic

Reference Decimal standard

lz_quantize

The left number rounded to as many places as the right number has.

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

The left number rounded to as many places after the point as the right one has; the right one's digits are not read. A tie goes to the even digit, so 2.25 to one place is 2.2. Places are counted in each number's own base: hexadecimal 0.8 has one place, so 21.375 quantized to it is 21.4, and the answer stays in the left operand's base.

Examples

CallAnswer
lz_quantize( 2.17, 0.01 )2.17
lz_quantize( 2.25, 0.1 )2.2
lz_quantize( 21.375, 0x0.8 )21.4
lz_quantize( 0x15.6, 0.5 )15.6 base 16

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_same_quantum Whether two numbers have the same number of places after the point.
  • lz_round The number rounded in its own rounding mode, half-even by default.
  • lz_normalize The number with its trailing noughts after the point removed.