fix(core): the shares keep the old scale, and the floor's correction is bounded
The review's kernel findings, with the bridge properties that hold them. FirstAbsorbs computed the first part as whole minus the rest, which is algebraically the old split_first's parts[0] + (whole minus the sum of parts) but not the same scale: 4860 by 6/0.7/0.5 gave 4050.00 where the old code gave 4050, and 902 by 1/0.000001/0.000001 gave 902 where the old code gave 902.00. That scale reaches Part.amount, so a printed share moved. The kernel computes the old expression now, with checked ops; LastAbsorbs was already the old plug_last and the no-places conventions split. The bridge compares the strings. share_floor_with's correction loop could walk without end on a rounded product far from the exact floor: 0.1113 x 5909471247797156928749568911.8 / 0.11134381908633486049673 hangs. Both directions now stop at MAX_CORRECTION_STEPS and refuse, so an input past the cap is None, never a hang; no figure produced within the cap changes. The bridge pins the input. Ranking needed a property of its own: on i64 every remainder is zero, so the harnesses never rank. A random-weight bridge checks the split against the independent exact reference over non-terminating totals, excluding exact ties because the kernel ranks the rounded quotients' remainders; finding_ties_follow_the_rounded_quotient pins those ties (20.00 by 4/1/1 over 6 is 13.33/3.34/3.33, 20 whole is 13/4/3), today's behaviour and the pre-U3 sites' alike, for K-U10 to decide. share_floor and split_by_weights had no engine caller (only the bridge), so they are gone; split_by_weights_with and share_floor_with are the public API, and the docs say both checked_mul and checked_div can round at Decimal's edge. Co-Authored-By: DeepSeek V4.1 Flash <noreply@opencode.ai>
This commit is contained in:
1 parent
d4440b6a4e
commit
8edc2e85dd
6 files changed
+313
-82
No files matched your search
@@ -451,8 +451,9 @@ fn original_target(
|
||||
|
||||
/// Split `whole` (at most the sum of `sizes`) over `sizes` in proportion,
|
||||
/// to the cent, leftover cents by largest remainder (k1's
|
||||
/// share_property), ties to the earlier in `order` (each part's rank).
|
||||
/// None past exact arithmetic.
|
||||
/// `share_property`), a tie in the rounded remainders to the earlier in
|
||||
/// `order` (each part's rank); an exact tie follows the quotient's 28th
|
||||
/// digit, and K-U10 decides the exact ranking. None past exact arithmetic.
|
||||
fn share_by(whole: Decimal, sizes: &[Decimal], order: &[usize]) -> Option<Vec<Decimal>> {
|
||||
let ranked: Vec<Decimal> = order.iter().map(|&i| sizes[i]).collect();
|
||||
let shared = crate::k1::share_property(whole, &ranked, 2).ok()?;
|
||||
|
||||
Reference in new issue
Block a user