Micah Cowan wrote:
> Patrick Amstutz wrote:
>> Hi,
>>
>> I've the following behavior with the seq function on:
>>
>> Linux version 2.6.18.8-0.3-default ([EMAIL PROTECTED]) (gcc version
>> 4.1.220061115 (prerelease) (SUSE Linux)) #1
>>
>> $ echo `seq 0.0 0.1 0.8`
>> 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8
>> $ echo `seq 0.0 0.1 0.9`
>> 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8
> 
> Actually, not a bug. This behavior is described in the info manual
> ("info seq" or "info coreutils seq"), and has to do with the limitations
> of binary floating point types; look for the line starting "Be careful
> when using `seq' with a fractional INCREMENT".
> 
> You need to use something more like:
> $ echo `seq 0.0 0.1 0.91`
> 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9

The issue and work around are documented in the info page,
but why don't we do the suggestion automatically in code
(using the precision that is automatically worked out already)?
Users of seq should not need to know about the specifics of floating
point representations.

Another thing I just noticed. I would expect the precision
of all output in the following command to be to 2 decimal places not 1:

$ seq 0.00 0.01 0.90 | grep "\.[0-9]$"
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9

Pádraig.


_______________________________________________
Bug-coreutils mailing list
Bug-coreutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-coreutils

Reply via email to