diff --git a/crates/proof-of-sql-parser/src/intermediate_decimal.rs b/crates/proof-of-sql-parser/src/intermediate_decimal.rs index 33356681e..f80a84ba3 100644 --- a/crates/proof-of-sql-parser/src/intermediate_decimal.rs +++ b/crates/proof-of-sql-parser/src/intermediate_decimal.rs @@ -56,13 +56,19 @@ impl IntermediateDecimal { /// Get the precision of the fixed-point representation of this intermediate decimal. #[must_use] pub fn precision(&self) -> u8 { - self.value.digits() as u8 + match u8::try_from(self.value.digits()) { + Ok(v) => v, + Err(_) => u8::MAX, // Returning u8::MAX on truncation + } } /// Get the scale of the fixed-point representation of this intermediate decimal. #[must_use] pub fn scale(&self) -> i8 { - self.value.fractional_digit_count() as i8 + match i8::try_from(self.value.fractional_digit_count()) { + Ok(v) => v, + Err(_) => i8::MAX, // Returning i8::MAX on truncation + } } /// Attempts to convert the decimal to `BigInt` while adjusting it to the specified precision and scale.