diff --git a/src/uucore/src/lib/features/format/num_format.rs b/src/uucore/src/lib/features/format/num_format.rs index 325da3ce6e3..ea5d6a75316 100644 --- a/src/uucore/src/lib/features/format/num_format.rs +++ b/src/uucore/src/lib/features/format/num_format.rs @@ -146,10 +146,10 @@ impl Formatter for UnsignedInt { // We also need to take into account that 0 should not be 00 // Since this is an unsigned int, we do not need to take the minus // sign into account. - if x != 0 { - format!("0{x:o}") - } else { + if x == 0 { format!("{x:o}") + } else { + format!("0{x:o}") } } UnsignedIntVariant::Hexadecimal(Case::Lowercase, Prefix::No) => {