dec2base test failure
Jaroslav Hajek
highegg at gmail.com
Wed Apr 15 12:43:45 CDT 2009
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)?.
>
>
I don't see the problem in my build; but since scalar .^ range is now
evaluated by repeatedly multiplying
scalar^base by scalar^increment, I see where the problem may come
from. I will try to make the operation more robust with integer
ranges.
--
RNDr. Jaroslav Hajek
computing expert & GNU Octave developer
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz
More information about the Bug-octave
mailing list