[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
## Re: puzzling Octave behaviour

**From**: |
Francesco Potorti` |

**Subject**: |
Re: puzzling Octave behaviour |

**Date**: |
Mon, 24 Jul 2006 10:34:58 +0200 |

>*The real problem is that testing doubles for equality doesn't *
>*work very well. It doesn't have anything to do with Octave, it's *
>*just a property of the floating point representation that *
>*computers use. You need to test to see if the numbers are close, *
>*within some tolerance, like (a - b) < 1e-10, instead of a == b.*
You example is wrong, because it should use abs().
Moreover, it assumes that you know the range of values of a and b. For
example, it gives wrong results if a and b are in the order of 1e-10. A
better test would be something like
abs(a-b) < 10*abs(a)*eps
--
Francesco PotortÃ¬ (ricercatore) Voice: +39 050 315 3058 (op.2111)
ISTI - Area della ricerca CNR Fax: +39 050 315 2040
via G. Moruzzi 1, I-56124 Pisa Email: address@hidden
Web: http://fly.isti.cnr.it/ Key: fly.isti.cnr.it/public.key

**puzzling Octave behaviour**, *Joan Picanyol i Puig*, `2006/07/22`
**Re: puzzling Octave behaviour**, *Muthiah Annamalai*, `2006/07/22`
**Re: puzzling Octave behaviour**, *Tom Holroyd*, `2006/07/22`
**Re: puzzling Octave behaviour**,
*Francesco Potorti`* **<=**
**checking for tiny inequalities (was: Re: puzzling Octave behaviour)**, *Joan Picanyol i Puig*, `2006/07/24`
**Re: checking for tiny inequalities (was: Re: puzzling Octave behaviour)**, *Bill Denney*, `2006/07/24`
**Re: checking for tiny inequalities (was: Re: puzzling Octave behaviour)**, *Przemek Klosowski*, `2006/07/24`
**Re: checking for tiny inequalities (was: Re: puzzling Octave behaviour)**, *Francesco Potorti*, `2006/07/24`
**Re: checking for tiny inequalities (was: Re: puzzling Octave behaviour)**, *Joan Picanyol i Puig*, `2006/07/30`