wrong comparison result
Sergei Steshenko
sergstesh at yahoo.com
Mon Mar 2 09:52:17 CST 2009
--- On Sun, 3/1/09, Jaroslav Hajek <highegg at gmail.com> wrote:
> From: Jaroslav Hajek <highegg at gmail.com>
> Subject: Re: wrong comparison result
> To: idohlp at neto.net.il
> Cc: bug at octave.org
> Date: Sunday, March 1, 2009, 11:42 PM
> 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
>
If one needs infinite precision numbers, he/she should consider other
programs from the CAS (Computer Algebra System) category - like Maxima, Axiom, GAP and many others.
These programs support rational fractions, i.e. numbers in the
nominator/denominator form.
At the same time infinite precision arithmetic is typically slower.
...
'octave-forge' has 'symbolic' package based on GINAC - I think GINAC itself
supports infinite precision numbers, but I'm not sure how complete
'octave-interface' to GINAC is.
Regards,
Sergei.
More information about the Bug-octave
mailing list