Re: common issue with version_compare()

From: Date: Sat, 21 Jul 2012 10:09:07 +0000
Subject: Re: common issue with version_compare()
References: 1 2 3 4 5 6  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message
If you think 1.1 =/= 1.01 you're sure using some weird version numbers.
Only 1.0.1 would be smaller.

Has anyone seen these weird version ordering schemes in practise? On any
major projects of note?
On Jul 21, 2012 10:51 AM, "Tjerk Meesters" <[email protected]> wrote:

>
>
> On 21 Jul, 2012, at 2:22 PM, Kris Craig <[email protected]> wrote:
>
> >>    1.01 eq 1.1
> >
> > Could you explain this one to me?  In every versioning system I've ever
> > used, 1.1 would be greater than 1.01, not equal.
>
> Because 01 is just a padded version of 1, probably used to make it easier
> for regular string comparisons (until you reach major version 10).
>
> >
> >> On Fri, Jul 20, 2012 at 5:07 PM, Stas Malyshev <[email protected]
> >> wrote:
> >>
> >>> Hi!
> >>>
> >>>>> For example, I was not the only one who found it odd that "1.0"
> >>>>> is
> >>>>> considered less than "1.0.0" - wouldn't it make sense to
> >>>>> "pad" the
> >>> shortest
> >>>>> version-number with zeroes? e.g. "1.0" if compared against
> >>>>> "1.0.0"
> >>> would be
> >>>>> padded with zeroes at the end, e.g. as "1.0.0".
> >>>
> >>> 1.0.0 and 1.0 are different things. If you want to make a comparison
> >>> that takes into account only two components, you can just cut them both
> >>> to two components, then compare.
> >>> --
> >>> Stanislav Malyshev, Software Architect
> >>> SugarCRM: http://www.sugarcrm.com/
> >>> (408)454-6900 ext. 227
> >>>
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Thread (21 messages)

« previous php.internals (#61614) next »