[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: strange problem
From: |
Christoph Dalitz |
Subject: |
Re: strange problem |
Date: |
Fri, 28 Nov 2003 10:00:36 +0100 |
On Fri, 28 Nov 2003 02:34:07 -0600 (CST)
Mike Miller <address@hidden> wrote:
>
> > > 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 some strange reason I believed that there was no "round" function because
it is not documented ("help round" gives "help: sorry, `round' is not
documented").
> You could write a function that performs that operation on matrices.
>
Tried this with:
function y = round(x,n)
y = round(x*10^n)/10^n;
endfunction
It seems however that Octave does not support function overloading, because
I obtain the error
octave:3> round(5.4,0)
error: round: too many arguments
I am using Octave 2.1.35. Is function overloading supported in some later
version?
Thanks,
Christoph
-------------------------------------------------------------
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
strange problem, John W. Eaton, 2003/11/28