docs(zset): drop the withdrawn premise from the overflow paragraph (improvise-tk51)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VdfEGXA7aJ6ftMsCc9PJze
This commit is contained in:
committed by
Edward Langley
parent
6de889a116
commit
d1665f6499
@@ -59,9 +59,8 @@ These are the readings this step takes.
|
||||
is required only where a result copies keys (`filter`, `distinct`, `scale`, the borrowed
|
||||
operators); `map` and the by-value operators need only `Ord`.
|
||||
5. **Overflow.** Neither clause 1 nor clause 8 states a policy for weights (clause 8 is about
|
||||
`f64` sums). A weight that wraps would turn a retraction into an insertion with nothing
|
||||
to show it, which is the failure the ADR's exactness argument is against. So every weight
|
||||
operation uses `checked_*` and **panics** with `zset: weight overflow in <op>`, in debug
|
||||
`f64` drift, which wrapping integers do not have). The crate currently uses `checked_*`
|
||||
on every weight operation, for the reason given below, and **panics** with `zset: weight overflow in <op>`, in debug
|
||||
and in release (`checked_*` does not depend on `overflow-checks`). The operations are
|
||||
`add` (including `insert`, `Extend`, `FromIterator`), `sub`, `neg` (so `i64::MIN` panics
|
||||
when it has to be negated) and `scale`. Scaling by zero cannot overflow and returns the
|
||||
@@ -79,7 +78,8 @@ These are the readings this step takes.
|
||||
under wrapping. (An earlier version of this paragraph said otherwise; that was wrong.) What
|
||||
wrapping breaks is the intermediate reads. `MAX + 1` stores `i64::MIN`, so `distinct`
|
||||
drops a key whose true weight is positive and `weight()` has the wrong sign. A true weight
|
||||
of 2^64 stores as 0, so the key vanishes and `is_zero`, `len` and `==` report a set that
|
||||
of 2^64 stores as 0 (by the add path; a `scale` product of 2^64 would store a zero too, which
|
||||
breaks canonical form), so the key vanishes and `is_zero`, `len` and `==` report a set that
|
||||
does not exist. Those are wrong answers returned silently, which is why the crate panics
|
||||
instead. A wider weight (`i128`) moves the boundary and does not remove it. The ADR's
|
||||
"abelian group" wording needs amending whichever policy is chosen: checked-and-panic gives
|
||||
|
||||
Reference in New Issue
Block a user