[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
seq problem representing zero
From: |
Simone Pascarosa |
Subject: |
seq problem representing zero |
Date: |
Sat, 08 Oct 2005 12:23:42 +0200 |
User-agent: |
Debian Thunderbird 1.0.2 (X11/20050602) |
Hi all,
my name is Simone Pascarosa.
I'm reporting a problem I've found on seq command:
I'm using seq (coreutils) 5.2.1 on an IBook G4 (PowerPC architecture)
with Debian GNU/Linux 3.1 "etch", with Linux 2.6.13.2.
When I use a non-integer number as increment, seq fails representing the
number 0.
For instance:
> seq -3 0.6 1
outputs:
-3
-2.4
-1.8
-1.2
-0.6
-1.11022e-16 <==
0.6
The number highlighted must be 0, but it is approximated to
-1.11022*10^(-16); in fact -0.000000000000000111022 is "almost" 0, but
it's not!
Maybe this is just a problem with my math libraries or similar.
The same problems happens when using values:
given k non integer
> seq -(k*n) k x
where n is an integer value and x>-(k*n-1)
(I think) :)
The problem disappears using --format option; for instance:
> seq --format="%1.1f" -6 1.2 1
outputs:
-6.0
-4.8
-3.6
-2.4
-1.2
-0.0
Typing:
> seq --format="%1.20f" -6 1.2 1
outputs:
-6.00000000000000000000
-4.79999999999999982236
-3.60000000000000008882
-2.40000000000000035527
-1.20000000000000017764
-0.00000000000000022204 <==
I think it's only a problem with the representation of real numbers, but
the output could be unhappy :)
Thanks for your daily job!
Simone Pascarosa
address@hidden
GNU/Linux User Group Perugia
- seq problem representing zero,
Simone Pascarosa <=