refactor(package): Decimal arithmetic goes through the kernel (K-U12)
The raw-decimal-arith detector counted 13 places in ledger-package before and counts 0 after. No figure changes. Negations go through money::neg; the two differences of books figures (attention, k1_tax) through sub_in_range; the checked sums in the attention checks through Amount::checked_add / checked_sub with their "cannot compute" handling untouched. Not a plain sum or sign: text.rs padded a number to two places with rescale (which rounds when 96 bits do not hold the padded digits); it now uses rescale_exact and keeps the number as it was if padding would round, so the printed text never rounds. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
1 parent
0fb19b4b25
commit
5ef5f47ebf
5 files changed
+17
-13
No files matched your search
@@ -27,7 +27,7 @@ pub fn money(n: Decimal) -> String {
|
||||
// is what drops a negative zero.
|
||||
let mut n = ledger_import::round_display(n, n.scale().max(2));
|
||||
if n.scale() < 2 {
|
||||
n.rescale(2);
|
||||
n = ledger_core::kernel::rescale_exact(n, 2).unwrap_or(n);
|
||||
}
|
||||
n.to_string()
|
||||
}
|
||||
@@ -47,7 +47,7 @@ pub fn share_text(n: Decimal) -> String {
|
||||
let mut n = n.normalize();
|
||||
n = ledger_import::round_display(n, n.scale().max(2));
|
||||
if n.scale() < 2 {
|
||||
n.rescale(2);
|
||||
n = ledger_core::kernel::rescale_exact(n, 2).unwrap_or(n);
|
||||
}
|
||||
n.to_string()
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user