pub fn negate_python(number: Decimal) -> DecimalExpand description
Negate with Python decimal’s sign rule for zero.
Python defines unary minus as 0 - x, so negating ANY zero yields a
POSITIVE zero:
-Decimal("0.00") == 0.00
-Decimal("-0.00") == 0.00rust_decimal’s Neg flips the sign bit unconditionally, so -dec!(0.00)
is a signed zero that renders -0.00. beancount normalizes it away — a
ledger posting written -0.00 CNY loads as Decimal('0.00') there, and
bean-query prints 0.00 — while rledger’s parser applies the sign with a
bare -n and kept the -0.00 all the way to the output.
A zero has no sign in bookkeeping; this is the canonical negation for any site that flips a parsed or computed amount.