bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: SEQ BUG


From: Pádraig Brady
Subject: Re: SEQ BUG
Date: Thu, 07 Jun 2007 21:57:35 +0100
User-agent: Thunderbird 1.5.0.8 (X11/20061116)

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 (address@hidden) (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.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]