integer radix convert: insert one zero digit in case value is zero

This commit is contained in:
Michael Sippel 2024-08-09 02:31:26 +02:00
parent 8d637a6f32
commit 786866746c
Signed by: senvas
GPG key ID: F96CF119C34B64A6

View file

@ -113,11 +113,15 @@ impl RadixProjection {
if let Some(src) = self.src.as_ref() { if let Some(src) = self.src.as_ref() {
let mut val = src.get_value(); let mut val = src.get_value();
if val == 0 {
self.dst_digits.push(0);
} else {
while val > 0 { while val > 0 {
self.dst_digits.push(val % self.dst_radix); self.dst_digits.push(val % self.dst_radix);
val /= self.dst_radix; val /= self.dst_radix;
} }
} }
}
let new_len = self.dst_digits.len(); let new_len = self.dst_digits.len();
for i in 0 .. usize::max(old_len, new_len) { for i in 0 .. usize::max(old_len, new_len) {