From f026b7a3ad67e727bac35edb8a4fdd4177a4a10c Mon Sep 17 00:00:00 2001 From: FidelSch Date: Wed, 3 Dec 2025 16:41:13 -0300 Subject: [PATCH 1/2] seq: calculate number length more efficiently --- src/uu/seq/src/seq.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/uu/seq/src/seq.rs b/src/uu/seq/src/seq.rs index 7b56c26f574..b67543e9254 100644 --- a/src/uu/seq/src/seq.rs +++ b/src/uu/seq/src/seq.rs @@ -290,8 +290,8 @@ fn fast_print_seq( // Format the first number. let first_str = first.to_string(); - // Makeshift log10.ceil - let last_length = last.to_string().len(); + // Approximate length of the last number in base 10. + let last_length = (last.bits() as f64 / std::f64::consts::LOG2_10).ceil() as usize; // Allocate a large u8 buffer, that contains a preformatted string // of the number followed by the `separator`. From 43b0ca51db48e378e1685b86e355559ed34d36cd Mon Sep 17 00:00:00 2001 From: FidelSch Date: Wed, 11 Feb 2026 10:43:43 -0300 Subject: [PATCH 2/2] seq: Update extensions.md Clarify seq output accuracy and value range limitations compared to GNU coreutils. --- docs/src/extensions.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/src/extensions.md b/docs/src/extensions.md index 9ea979e9571..437448837b0 100644 --- a/docs/src/extensions.md +++ b/docs/src/extensions.md @@ -145,6 +145,8 @@ matter the parameters (integers, decimal numbers, positive or negative increment format specified, etc.), so its output will be more correct than GNU coreutils for some inputs (e.g. small fractional increments where GNU coreutils uses `long double`). +This also extends the range of values that can be represented beyond GNU coreutils' `long double` maximum. + The only limitation is that the position of the decimal point is stored in a `i64`, so values smaller than 10**(-2**63) will underflow to 0, and some values larger than 10**(2**63) may overflow to infinity.