help-octave
[Top][All Lists]
Advanced

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

Re: [OctDev] Misleading documentation for `chop'


From: Carnë Draug
Subject: Re: [OctDev] Misleading documentation for `chop'
Date: Mon, 28 May 2012 02:24:21 +0100

On 26 May 2012 21:35, Andrej Lajovic <address@hidden> wrote:
> Hi,
>
> there has recently been a mention of the "chop" function. I was not aware
> of its existence until then and decided to give it a try. However, I have
> found the documentation to be somewhat misleading. It says:
>
>> -- Function File:  chop (X, NDIGITS, BASE)
>>     Truncate elements of X to a length of NDIGITS such that the
>>     resulting numbers are exactly divisible by BASE.  If BASE is not
>>     specified it defaults to 10.
>
> To me, the last sentence clearly means that calling
>
>> chop(X, NDIGITS)
>
> should give an identical result to
>
>> chop(X, NDIGITS, 10)
>
> But this is not the case:
>
>> octave:1> chop(pi, 5)
>> ans =  3.1416
>
>> octave:2> chop(pi, 5, 10)
>> ans =  3.1420
>
> It seems that calling the function with two arguments rounds the number X to
> NDIGITS significant figures in base 10, whereas calling it with three
> arguments rounds the number X to NDIGITS significant figures in base 10
> while also making these NDIGITS significant figures divisible by BASE. These
> two cases are not the same and the distinction is, in my opinion, not made
> clearly enough in the documentation.
>
> What do you think?
>
>
> Andrej

Hi Andrej

the chop function belongs to octave core, not to an octave package, so
you should mention this on the octave mailing list (I'm CC'ing it)

Not sure if this is bug. Looking at the source of chop it looks like
the base should default to 10. However, looking further down the code,
if nargin != 2, it's value is completely ignored. You may need to
report it on the octave bug tracker
https://savannah.gnu.org/bugs/?group=octave

Carnë


reply via email to

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