Marc Mutz <[EMAIL PROTECTED]> writes:
| $ seq -s' ' 10 # this is as I expect
| 1 2 3 4 5 6 7 8 9 10
| $ seq -s' ' 1 1 10 # this is also as I expect
| 1 2 3 4 5 6 7 8 9 10
| $ seq -s' ' 0 0.1 1 # this seems wrong, as it doesn't include the 1.0
| 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9
That's because `seq' is implemented using binary floating point arithmetic
(via the C `double' type) -- which means some decimal numbers like 0.1
cannot be represented exactly. That in turn means some nonintuitive
conditions like `0.1 * 10 < 1.0' will end up being `true'.
To work around that, use `1.01' as the LAST value:
$ seq -s' ' 0 0.1 1.01
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
In general, ...
When using an INCREMENT with a fractional part, where
(LAST - FIRST) / INCREMENT is (mathematically) a whole number,
specify a slightly larger (or smaller, if INCREMENT is negative)
value for LAST to ensure that LAST is the final value printed by seq.