Skip to content

Commit

Permalink
Merge pull request uutils#6928 from artP2/scientific-notation-upperca…
Browse files Browse the repository at this point in the history
…se-E

seq: handle scientific notation with uppercase 'E'
  • Loading branch information
cakebaker authored Dec 7, 2024
2 parents c8bcdb9 + 88e1047 commit f7c38a3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/uu/seq/src/numberparse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ impl FromStr for PreciseNumber {
// number differently depending on its form. This is important
// because the form of the input dictates how the output will be
// presented.
match (s.find('.'), s.find('e')) {
match (s.find('.'), s.find(['e', 'E'])) {
// For example, "123456" or "inf".
(None, None) => parse_no_decimal_no_exponent(s),
// For example, "123e456" or "1e-2".
Expand Down Expand Up @@ -392,6 +392,7 @@ mod tests {
fn test_parse_big_int() {
assert_eq!(parse("0"), ExtendedBigDecimal::zero());
assert_eq!(parse("0.1e1"), ExtendedBigDecimal::one());
assert_eq!(parse("0.1E1"), ExtendedBigDecimal::one());
assert_eq!(
parse("1.0e1"),
ExtendedBigDecimal::BigDecimal("10".parse::<BigDecimal>().unwrap())
Expand Down
5 changes: 5 additions & 0 deletions tests/by-util/test_seq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,11 @@ fn test_width_scientific_notation() {
.succeeds()
.stdout_is("0999\n1000\n")
.no_stderr();
new_ucmd!()
.args(&["-w", "999", "1E3"])
.succeeds()
.stdout_is("0999\n1000\n")
.no_stderr();
}

#[test]
Expand Down

0 comments on commit f7c38a3

Please sign in to comment.