[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: strange problem
From: |
Mike Miller |
Subject: |
Re: strange problem |
Date: |
Fri, 28 Nov 2003 02:34:07 -0600 (CST) |
On Fri, 28 Nov 2003, Christoph Dalitz wrote:
> On Thu, 27 Nov 2003 23:03:26 +0000
> Geraint Paul Bevan <address@hidden> wrote:
> > |
> > | -2.0817e-17 1.0000e+02
> > | -1.0000e-02 1.0000e+00
> > |
> >
> > The number -2.0817e-17 is -0.000000000000000020817, which is very, very
> > close to zero.
>
> Is there an Octave function that truncates/rounds such small numbers to
> zero (like the Scilab function "clean")?
>
> I have tried "help round" and "help trunc", but found nothing
> appropriate.
Why not use 'round' but first multiply by a large number, then divide by
that same number after round. For example:
octave:1> x=-2.0817e-17
x = -2.0817e-17
octave:2> round(x*1e+15)/1e+15
ans = 0
You could write a function that performs that operation on matrices.
Mike
-------------------------------------------------------------
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
-------------------------------------------------------------
Message not available