merge: every report and book total goes through the kernel's checked sum (K-U4; branch t3/kernel-checked-totals, bc81b849; reviewed)
periods.rs conflicted with K-U2: the frozen replay rules delegate to K-U4's checked twins, whose rounding now goes through K-U2's round_places (so every rounding stays in the kernel); no figure changes. The K-U4 note gains the review's list of bounded raw sums left, and the caveat that the twin test checks delegation (the review's independent 20,000-case comparison found the twins identical). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
57d86b1920
25 files changed
+1184
-229
No files matched your search
@@ -704,9 +704,7 @@ fn entry_buckets(
|
||||
}
|
||||
|
||||
fn sum3(b: [Decimal; 3]) -> Result<Decimal, LedgerError> {
|
||||
b[0].checked_add(b[1])
|
||||
.and_then(|s| s.checked_add(b[2]))
|
||||
.ok_or_else(|| LedgerError::TooLargeToCompute("a payment's buckets".into()))
|
||||
kernel::total(b).ok_or_else(|| LedgerError::TooLargeToCompute("a payment's buckets".into()))
|
||||
}
|
||||
|
||||
/// The vendor's part of `payment` when the entry names several parties:
|
||||
@@ -768,13 +766,13 @@ fn split_share(b: [Decimal; 3], v: Decimal) -> Result<[Decimal; 3], LedgerError>
|
||||
let mut part =
|
||||
kernel::round_places(q, 2, kernel::Rounding::TowardZero).ok_or_else(too_large)?;
|
||||
while times(part)? > num {
|
||||
part -= cent;
|
||||
part = part.checked_sub(cent).ok_or_else(too_large)?;
|
||||
}
|
||||
while times(part + cent)? <= num {
|
||||
part += cent;
|
||||
while times(part.checked_add(cent).ok_or_else(too_large)?)? <= num {
|
||||
part = part.checked_add(cent).ok_or_else(too_large)?;
|
||||
}
|
||||
// The remainder, over the common denominator ap.
|
||||
rems[i] = num - times(part)?;
|
||||
rems[i] = num.checked_sub(times(part)?).ok_or_else(too_large)?;
|
||||
parts[i] = part;
|
||||
}
|
||||
kernel::apportion(av, &mut parts, &rems, cent).ok_or_else(too_large)?;
|
||||
|
||||
Reference in new issue
Block a user