1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-30 04:27:45 +00:00

seq: Reverted change in is_minus_zero check

I had made the mistake of not running all the tests. This is indeed needed. However, you still need to add the exponent if it's positive for 0 numbers.
This way, 0 numbers (such as 0e+5) will be counted as having a width of 5.

This change also removes the memory allocation needed for the previous implementation. Where the string itself would be padded with zeros on the right side. Creating large numbers this method would cause large allocations in memory.

This does not seem to fix issue #6182.
This commit is contained in:
maxer137 2024-04-03 19:20:27 +02:00
parent 362deeca84
commit cdfcae4d4f

View file

@ -104,16 +104,24 @@ fn parse_exponent_no_decimal(s: &str, j: usize) -> Result<PreciseNumber, ParseNu
// without a decimal point.
let x: BigDecimal = s.parse().map_err(|_| ParseNumberError::Float)?;
let total = j as i64 + exponent;
let result = if total < 1 {
1
let num_integral_digits = if is_minus_zero_float(s, &x) {
if exponent > 0 {
2usize + exponent as usize
} else {
2usize
}
} else {
total.try_into().unwrap()
};
let num_integral_digits = if x.sign() == Sign::Minus {
result + 1
} else {
result
let total = j as i64 + exponent;
let result = if total < 1 {
1
} else {
total.try_into().unwrap()
};
if x.sign() == Sign::Minus {
result + 1
} else {
result
}
};
let num_fractional_digits = if exponent < 0 { -exponent as usize } else { 0 };