Skip to content

Commit

Permalink
seq:minor updates for write_value_float
Browse files Browse the repository at this point in the history
  • Loading branch information
alexs-sh committed Jan 4, 2025
1 parent 4f7a02a commit 642eb1a
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/uu/seq/src/seq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,22 +235,21 @@ fn write_value_float(
width: usize,
precision: Option<usize>,
) -> std::io::Result<()> {
let value_as_str = if let Some(precision) = precision {
let value_as_str = match precision {
// format with precision: decimal floats and integers
match value {
Some(precision) => match value {
ExtendedBigDecimal::Infinity | ExtendedBigDecimal::MinusInfinity => {
format!("{value:>width$.precision$}")
}
_ => format!("{value:>0width$.precision$}"),
}
} else {
},
// format without precision: hexadecimal floats
match value {
None => match value {
ExtendedBigDecimal::BigDecimal(bd) => {
format_bigdecimal(bd).unwrap_or("{value}".to_owned())
format_bigdecimal(bd).unwrap_or_else(|| "{value}".to_owned())
}
_ => format!("{value:>0width$}"),
}
},
};
write!(writer, "{value_as_str}")
}
Expand Down

0 comments on commit 642eb1a

Please sign in to comment.