dec2base test failure
Ivan Sutoris
ivan.sutoris at gmail.com
Thu Apr 16 04:18:17 CDT 2009
On Thu, Apr 16, 2009 at 8:30 AM, Jaroslav Hajek <highegg at gmail.com> wrote:
> On Wed, Apr 15, 2009 at 7:06 PM, Ivan Sutoris <ivan.sutoris at gmail.com> wrote:
>> Bug report for Octave 3.1.55 configured for i686-pc-linux-gnu
>>
>> Description:
>> -----------
>>
>> After compiling development sources today (tip 9122:8ca06fd9c6ef), I
>> have noticed test failure at dec2base function (computes string
>> representation of number in other bases), which returned wrong result
>> for this input:
>>
>> dec2base(125, 5)
>> ans = 1044
>>
>> Correct result should be 1000 (125 = 5^3). Has anyone else encountered this?
>>
>> I think the problem happens at line 87, where expression
>>
>> power = ones (length (n), 1) * (base .^ (max_len-1 : -1 : 0));
>>
>> should evaluate to [125 25 5 1] (in this case, n=125, base=5,
>> max_len=4), but the actual result deviates slightly:
>>
>> debug> power - [125 25 5 1]
>> ans =
>>
>> 0.0000e+00 0.0000e+00 8.8818e-16 2.2204e-16
>>
>> This causes problem later at line 89, when digits are computed using
>> division remainder (for example, compare results of rem(125,5) and
>> rem(125, 5 + 10^-15)). I see that Jaroslav optimized scalar .^ range
>> operations recently, so maybe this is related to those changes (I
>> think this was not problem before)?.
>>
>>
>
>
> Pleasy try with this patch:
> http://hg.savannah.gnu.org/hgweb/octave/rev/f39b98237d5c
>
> cheers
>
> --
> RNDr. Jaroslav Hajek
> computing expert & GNU Octave developer
> Aeronautical Research and Test Institute (VZLU)
> Prague, Czech Republic
> url: www.highegg.matfyz.cz
>
With fresh build the problem is gone, thanks for quick response (and
for creating patches at 7 AM :) )
Regards
Ivan Sutoris
More information about the Bug-octave
mailing list