From help-request at octave dot org Fri Oct 22 11:07:01 2004 Subject: Re: Comparing of values From: Miquel Cabanas To: Jakub Selesovsky Cc: help at octave dot org Date: Fri, 22 Oct 2004 18:02:42 +0200 hi, On Fri, Oct 22, 2004 at 03:40:11PM +0200, Jakub Selesovsky wrote: > > octave:12> beta(beta==0.15) > ans = [](0x1) > octave:13> beta(beta==0.05) > ans = > > 0.050000 > 0.050000 > 0.050000 > 0.050000 > 0.050000 > FWIW, it fails too when comparing to 0.30, 0.35, 0.60, 0.70 and 0.85 besides the 0.15 already mentioned. As pointed, it has to do with float numbers. If you do, beta .- 0.10 you will see some "0.00000" values that correspond to the values reported when using "==", but if you do beta .- 0.15 you will see that the exact zeros "0.00000" have been replaced with approximate zeros, i.e. "2.7756e-17" that in my machine are smaller than "eps", the machine precission (see help eps). It's odd, but a fix is to replace beta==0.15 with abs( beta .- 0.15 ) < eps Hope this helps, Miquel -- Miquel E Cabanas ------------------------------------------------------ SeRMN, Universitat Autonoma de Barcelona (Miquel dot Cabanas at uab dot es) MRUI Software Manager (mrui-mgr at mrui dot uab dot es) ------------------------------------------o-oo--ooo---ooo--oo-o-------- ------------------------------------------------------------- Octave is freely available under the terms of the GNU GPL. Octave's home on the web: http://www.octave.org How to fund new projects: http://www.octave.org/funding.html Subscription information: http://www.octave.org/archive.html -------------------------------------------------------------