Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:61598 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 59999 invoked from network); 21 Jul 2012 03:19:44 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 21 Jul 2012 03:19:44 -0000 Authentication-Results: pb1.pair.com header.from=rasmus@mindplay.dk; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=rasmus@mindplay.dk; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain mindplay.dk from 209.85.212.42 cause and error) X-PHP-List-Original-Sender: rasmus@mindplay.dk X-Host-Fingerprint: 209.85.212.42 mail-vb0-f42.google.com Received: from [209.85.212.42] ([209.85.212.42:64256] helo=mail-vb0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 86/F4-18983-FCF1A005 for ; Fri, 20 Jul 2012 23:19:43 -0400 Received: by vbbfs19 with SMTP id fs19so4076400vbb.29 for ; Fri, 20 Jul 2012 20:19:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:x-gm-message-state; bh=BF6JGddSvt+IoZ1AWvIfSex+KhXvU0Oa4vQpAKl61CM=; b=EStOHGLDju0MAe13dRmg2MXTy8WpOFvLQxrBTWnb981MyGRkplkh9rqSjd5PcY/pMV W++Fv5Wnwu69LH9P9W3GZdhELBwH1xgXvVarTzX9+F8ZTBIlxlSZ38IPJF1e++An9UjR HVQWG4NnwcqsPm2AsnEqAYtrr742K0Ev+X3ny0kjxiCsddTCzGu6tf/z91vomxdJBqXK 3Rk5VexanGJRGCx2LfYhKkkrq5Pyfrv7w3yOyyTpG8stqe8EwsajtGONLU5Z5NyrSPnf h7XNPmC7+HCoYFOFAcup/jmF4zfN5loXs3fXhk9XzBRtBO7cIqGPVrnJo5E8w1JCLqUm azzw== MIME-Version: 1.0 Received: by 10.52.94.197 with SMTP id de5mr5464576vdb.33.1342840780473; Fri, 20 Jul 2012 20:19:40 -0700 (PDT) Received: by 10.52.92.82 with HTTP; Fri, 20 Jul 2012 20:19:40 -0700 (PDT) In-Reply-To: <5009C8AA.10603@sugarcrm.com> References: <5009C8AA.10603@sugarcrm.com> Date: Fri, 20 Jul 2012 23:19:40 -0400 Message-ID: To: internals@lists.php.net Content-Type: multipart/alternative; boundary=20cf3071cffeb5c3be04c54e7b57 X-Gm-Message-State: ALoCoQkv/XXtpheSYJCxc7Hvgy6VET+mAr3A34qfriLzmtUAcpLVea6BgGVRtE+OoK8taNEtlGS5 Subject: Re: [PHP-DEV] common issue with version_compare() From: rasmus@mindplay.dk (Rasmus Schultz) --20cf3071cffeb5c3be04c54e7b57 Content-Type: text/plain; charset=ISO-8859-1 > 1.0.0 and 1.0 are different things. I think the problem is, version numbers are different things to different people - I guess the documentation maybe isn't clear enough on precisely what version numbering scheme it's using. To most people, "1" and "1.0" are the same thing, because they look like decimal-numbers to Americans. The documentation doesn't state how leading zeroes or missing numbers are treated in comparisons. I just submitted a comment with a small script that runs version_compare() on a list of version numbers - 1 lt 1.0 1.0 eq 1.00 1.00 lt 1.01 1.01 eq 1.1 1.1 lt 1.10 1.10 gt 1.10b 1.10b lt 1.10.0 I was a bit surprised at some of these, but they make sense now that I can see how the version-number interpretation works... On Fri, Jul 20, 2012 at 5:07 PM, Stas Malyshev 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 > --20cf3071cffeb5c3be04c54e7b57--