Skip to content

Commit d9af784

Browse files
committed
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.
1 parent ab15532 commit d9af784

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

src/uucore/src/lib/features/format/num_format.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -293,13 +293,7 @@ impl Formatter for Float {
293293

294294
let precision = match precision {
295295
Some(CanAsterisk::Fixed(x)) => x,
296-
None => {
297-
if matches!(variant, FloatVariant::Shortest) {
298-
6
299-
} else {
300-
0
301-
}
302-
}
296+
None => 6, // Default float precision (C standard)
303297
Some(CanAsterisk::Asterisk) => return Err(FormatError::WrongSpecType),
304298
};
305299

0 commit comments

Comments
 (0)