GNU bug report logs - #75994
"seq -w" is broken for large enough numbers

Previous Next

Package: coreutils;

Reported by: Alexey Dobriyan <adobriyan <at> gmail.com>

Date: Sat, 1 Feb 2025 17:45:01 UTC

Severity: wishlist

Full log


View this message in rfc822 format

From: Pádraig Brady <P <at> draigBrady.com>
To: Alexey Dobriyan <adobriyan <at> gmail.com>, 75994 <at> debbugs.gnu.org
Subject: bug#75994: "seq -w" is broken for large enough numbers
Date: Sat, 1 Feb 2025 20:01:18 +0000
On 01/02/2025 17:43, Alexey Dobriyan wrote:
> coreutils 9.3, 9.5
> 
> Steps to reproduce:
> 
> 	# 21 digits
> 	$ seq 111111111111111111111 1 111111111111111111113
> 	111111111111111111111
> 	111111111111111111112
> 	111111111111111111113

With no -w, seq doesn't use floating point
and instead operates on the ASCII values directly.

> 
> 	$ seq -w 111111111111111111111 1 111111111111111111113
> 	111111111111111111112	# what?
> 	111111111111111111112
> 	111111111111111111112
> 	111111111111111111112


With -w seq will use long doubles internally,
which usually have a 64 bit significand.
I.e. once you go above 2^64, you get approximations of integers.

Now we could adjust seq to use the "ASCII" increment method
in this case by handling leading zeros appropriately.
It would be good to know your use case here though,
as to know how common this issue might be.

cheers,
Pádraig




This bug report was last modified 123 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.