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

Re: dpkg doing wrong math (0.09 = 0.9) ?-



"Roberto C. Sanchez" <roberto@familiasanchez.net> writes:

> On Fri, Aug 11, 2006 at 01:29:40AM +0200, Adeodato Simó wrote:
>> * Michael Biebl [Fri, 11 Aug 2006 01:12:59 +0200]:
>> 
>> > that "dpkg --compare-versions '0.09' '=' '0.9'" yields true, which I
>> > think is rather odd, because it means that now all version numbers up to
>> > 0.9 will be considered < 0.09+0.1.
>> 
>>   0.09 = 0.9 means:
>> 
>>     0 == 0
>>     and
>>     . == .
>>     and
>>     09 == 9
>> 
>>   Which is pretty standard math. ;-)
>> 
> Except that the final comparison ignores that the number was to the
> right of the decimal, making the zero significant.  I think you will be
> hard pressed to find a mathematician who supports dropping significant
> zeros for no good reason.
>
> -Roberto

Well, lets go math (well, not totaly formal :):

Debian version 0.09 == 0:0.09 == {(0, "", 0), (1, "", 0), (2, ".", 09)}
Debian version 0.1  == 0:0.1  == {(0, "", 0), (1, "", 0), (2, ".", 1)}

Where two triplets of (id, s, n) are comparable for id1 == id2 and then s1
is compared to s2 first and only then n1 to n2.

Sets of those tripplets are compared by order of id comparing triplets
with matching ids and the first non-matching triplet decides the
order.

This confirms that 0.09 >> 0.1.

MfG
        Goswin

PS: ~ was ignored for simplicity.



Reply to: