From 786866746c049746ab1515a3454d7a60858f6345 Mon Sep 17 00:00:00 2001 From: Michael Sippel Date: Fri, 9 Aug 2024 02:31:26 +0200 Subject: [PATCH] integer radix convert: insert one zero digit in case value is zero --- lib-nested-core/src/editors/integer/radix.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib-nested-core/src/editors/integer/radix.rs b/lib-nested-core/src/editors/integer/radix.rs index 4c5cf31..36213a9 100644 --- a/lib-nested-core/src/editors/integer/radix.rs +++ b/lib-nested-core/src/editors/integer/radix.rs @@ -113,9 +113,13 @@ impl RadixProjection { if let Some(src) = self.src.as_ref() { let mut val = src.get_value(); - while val > 0 { - self.dst_digits.push(val % self.dst_radix); - val /= self.dst_radix; + if val == 0 { + self.dst_digits.push(0); + } else { + while val > 0 { + self.dst_digits.push(val % self.dst_radix); + val /= self.dst_radix; + } } }