From 59b20ab21aab7271b186090f851a6e42c6b8b724 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 e661b4f7a28..10a950fd1f4 100644 --- a/src/uu/seq/src/seq.rs +++ b/src/uu/seq/src/seq.rs @@ -309,8 +309,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 06f5ffc0976097747db267107414a6961739f217 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 489886394e2..77805f0432f 100644 --- a/docs/src/extensions.md +++ b/docs/src/extensions.md @@ -167,6 +167,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.