[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: SEQ BUG
From: |
John Cowan |
Subject: |
Re: SEQ BUG |
Date: |
Thu, 7 Jun 2007 16:07:56 -0400 |
User-agent: |
Mutt/1.5.13 (2006-08-11) |
Patrick Amstutz scripsit:
> $ 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
Welcome to floating-point roundoff errors. The decimal constant 0.1
cannot be exactly represented as a floating-point number on modern
hardware, so 0.1+0.1+0.1+0.1+0.1+0.1+0.1+0.1+0.1 is actually greater
than 0.9; consequently, 0.9 is not printed.
You should never iterate using floating-point fractions for this reason.
--
Where the wombat has walked, John Cowan <address@hidden>
it will inevitably walk again. http://www.ccil.org/~cowan
- Re: [PATCH] SEQ BUG, (continued)
- Re: [PATCH] SEQ BUG, Pádraig Brady, 2007/06/20
- Re: [PATCH] SEQ BUG, Paul Eggert, 2007/06/22
- Re: [PATCH] SEQ BUG, Pádraig Brady, 2007/06/22
- Re: [PATCH] SEQ BUG, Paul Eggert, 2007/06/22
- Re: [PATCH] SEQ BUG, Jim Meyering, 2007/06/22
- Re: [PATCH] SEQ BUG, Micah Cowan, 2007/06/22
- Re: [PATCH] SEQ BUG, Paul Eggert, 2007/06/22
- Re: [PATCH] SEQ BUG, Pádraig Brady, 2007/06/22
- Re: [PATCH] SEQ BUG, Paul Eggert, 2007/06/22
- Re: [PATCH] SEQ BUG, Jim Meyering, 2007/06/23
Re: SEQ BUG,
John Cowan <=