From 7b796ee0a4f938594c5f0380d7760e07916c0786 Mon Sep 17 00:00:00 2001 From: Malte Kliemann Date: Fri, 29 Sep 2023 00:16:31 +0200 Subject: [PATCH] Update primitives/src/math/fixed.rs Co-authored-by: Chralt --- primitives/src/math/fixed.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/primitives/src/math/fixed.rs b/primitives/src/math/fixed.rs index 0083799f3..f977563a2 100644 --- a/primitives/src/math/fixed.rs +++ b/primitives/src/math/fixed.rs @@ -253,7 +253,7 @@ impl> FromFixedToDecimal for N { let mut increment = false; let new_frac_part = if frac_part.len() < decimals_usize { - format!("{}{}", frac_part, "0".repeat(decimals_usize - frac_part.len())) + format!("{}{}", frac_part, "0".repeat(decimals_usize.saturating_sub(frac_part.len()))) } else { // Adding rounding behavior let round_digit = frac_part.chars().nth(decimals_usize);