bug-coreutils
[Top][All Lists]
Advanced

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

Re: SEQ BUG


From: Micah Cowan
Subject: Re: SEQ BUG
Date: Thu, 07 Jun 2007 14:30:25 -0700
User-agent: Thunderbird 1.5.0.12 (X11/20070604)

Pádraig Brady wrote:

> 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

I wouldn't. The documentation is fairly clear that the '%g' specifier is
what gets used by default. If you want something else, you need to
specify the format via the -f option; for example:

$ seq  -f %.2f 0.00 0.01 0.90| grep "\.[0-9]0$"
0.00
0.10
0.20
0.30
0.40
0.50
0.60
0.70
0.80
0.90

In any case, I think John's advice is wisest: don't use floating point
math for iteration. These are exactly the sorts of troubles you get when
doing so.

-- 
Micah J. Cowan
Programmer, musician, typesetting enthusiast, gamer...
http://micah.cowan.name/





reply via email to

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