tisonkun commented on code in PR #88:
URL: https://github.com/apache/datasketches-rust/pull/88#discussion_r2787915458


##########
datasketches/src/tdigest/sketch.rs:
##########
@@ -1251,15 +1251,24 @@ impl Centroid {
     fn add(&mut self, other: Centroid) {
         let (self_weight, other_weight) = (self.weight(), other.weight());
         let total_weight = self_weight + other_weight;
-        self.weight = self.weight.saturating_add(other.weight.get());
+        self.weight = self
+            .weight
+            .checked_add(other.weight.get())
+            .expect("weight overflow");

Review Comment:
   Instead of silently `saturating_add`, panic if overflow.
   
   This should never happen with real inputs, and let it crash should be better 
than silently holding inaccurate values.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to