integer radix convert: insert one zero digit in case value is zero
This commit is contained in:
parent
8d637a6f32
commit
786866746c
1 changed files with 7 additions and 3 deletions
|
@ -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) {
|
||||||
|
|
Loading…
Reference in a new issue