help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Comparing of values


From: Miquel Cabanas
Subject: Re: Comparing of values
Date: Fri, 22 Oct 2004 18:02:42 +0200
User-agent: Mutt/1.3.28i

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 (address@hidden)
MRUI Software Manager (address@hidden)
------------------------------------------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
-------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]