1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

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.
This commit is contained in:
Nicolas Boichat 2025-03-03 14:42:52 +01:00 committed by Dorian Péron
parent 0a8155b5c2
commit bfa8bf72c7

View file

@ -293,13 +293,7 @@ impl Formatter for Float {
let precision = match precision { let precision = match precision {
Some(CanAsterisk::Fixed(x)) => x, Some(CanAsterisk::Fixed(x)) => x,
None => { None => 6, // Default float precision (C standard)
if matches!(variant, FloatVariant::Shortest) {
6
} else {
0
}
}
Some(CanAsterisk::Asterisk) => return Err(FormatError::WrongSpecType), Some(CanAsterisk::Asterisk) => return Err(FormatError::WrongSpecType),
}; };