GNU bug report logs -
#75994
"seq -w" is broken for large enough numbers
Previous Next
Full log
View this message in rfc822 format
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.