wrong comparison result
Jaroslav Hajek
highegg at gmail.com
Mon Mar 2 01:42:19 CST 2009
On Sat, Feb 28, 2009 at 11:51 PM, Ido Halperin <idohlp at neto.net.il> wrote:
> >From ido at login.modem Sun Mar 01 00:45:43 2009
> Return-path: <ido at login.modem>
> Envelope-to: ido at login.modem
> Delivery-date: Sun, 01 Mar 2009 00:45:43 +0200
> Received: from ido by login.modem with local (Exim 4.69)
> (envelope-from <ido at login.modem>)
> id 1LdXwF-000126-SO; Sun, 01 Mar 2009 00:45:43 +0200
> To: bug at octave.org, ido at login.modem
> Subject: wrong comparison result
> Message-Id: <E1LdXwF-000126-SO at login.modem>
> From: idohalperin <ido at login.modem>
> Date: Sun, 01 Mar 2009 00:45:43 +0200
>
> To: bug at octave.org
> Cc: ido
> Subject: wrong comparison result
>
> Bug report for Octave 3.0.1 configured for i486-pc-linux-gnu
>
> Description:
> -----------
>
> The next code returns a right result:
>
> octave:4> [[47:49]/49]==1
> ans =
>
> 0 0 1
>
>
> but this code does not:
>
> octave:3> [[47:49]*[1/49]]==1
> ans =
>
> 0 0 0
>
> it is obvious that the 3rd cell should be "1".
>
>
No, it is not. Please read something about floating point numbers.
Wikipedia may be a good start:
http://en.wikipedia.org/wiki/Floating_point
cheers
--
RNDr. Jaroslav Hajek
computing expert
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz
More information about the Bug-octave
mailing list