mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-31 13:07:46 +00:00
seq: remove exponent exponent less than 0 check.
When exponent is greater than 0 we previously created a new string causing us to create a new string with a much larger size. This would the get passed to the BigDecimal crate which would get stuck.
This commit is contained in:
parent
efd7b6116c
commit
362deeca84
1 changed files with 11 additions and 17 deletions
|
@ -117,24 +117,18 @@ fn parse_exponent_no_decimal(s: &str, j: usize) -> Result<PreciseNumber, ParseNu
|
||||||
};
|
};
|
||||||
let num_fractional_digits = if exponent < 0 { -exponent as usize } else { 0 };
|
let num_fractional_digits = if exponent < 0 { -exponent as usize } else { 0 };
|
||||||
|
|
||||||
if exponent < 0 {
|
if is_minus_zero_float(s, &x) {
|
||||||
if is_minus_zero_float(s, &x) {
|
Ok(PreciseNumber::new(
|
||||||
Ok(PreciseNumber::new(
|
ExtendedBigDecimal::MinusZero,
|
||||||
ExtendedBigDecimal::MinusZero,
|
num_integral_digits,
|
||||||
num_integral_digits,
|
num_fractional_digits,
|
||||||
num_fractional_digits,
|
))
|
||||||
))
|
|
||||||
} else {
|
|
||||||
Ok(PreciseNumber::new(
|
|
||||||
ExtendedBigDecimal::BigDecimal(x),
|
|
||||||
num_integral_digits,
|
|
||||||
num_fractional_digits,
|
|
||||||
))
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
let zeros = "0".repeat(exponent.try_into().unwrap());
|
Ok(PreciseNumber::new(
|
||||||
let expanded = [&s[0..j], &zeros].concat();
|
ExtendedBigDecimal::BigDecimal(x),
|
||||||
parse_no_decimal_no_exponent(&expanded)
|
num_integral_digits,
|
||||||
|
num_fractional_digits,
|
||||||
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue