From bfa8bf72c749edfc575e3f69f1688cb71ea47198 Mon Sep 17 00:00:00 2001 From: Nicolas Boichat Date: Mon, 3 Mar 2025 14:42:52 +0100 Subject: [PATCH] uucore: format: Fix default Float precision in try_from_spec The default precision is 6, no matter the format. This applies to all float formats, not just "%g" (aka FloatVariant::Shortest). Fixes #7361. --- src/uucore/src/lib/features/format/num_format.rs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/uucore/src/lib/features/format/num_format.rs b/src/uucore/src/lib/features/format/num_format.rs index 6caf1bfce..fac733a22 100644 --- a/src/uucore/src/lib/features/format/num_format.rs +++ b/src/uucore/src/lib/features/format/num_format.rs @@ -293,13 +293,7 @@ impl Formatter for Float { let precision = match precision { Some(CanAsterisk::Fixed(x)) => x, - None => { - if matches!(variant, FloatVariant::Shortest) { - 6 - } else { - 0 - } - } + None => 6, // Default float precision (C standard) Some(CanAsterisk::Asterisk) => return Err(FormatError::WrongSpecType), };