Compare two version strings and return
-1 if $v1 is less and +1 if $v1 is greater
than $v2. Return 0 if versions are equal.

@param string $v1
@param string $v2
@return int
966116
public static function compare($v1, $v2){
        $v1 = new SoftwareVersion($v1);
        $v2 = new SoftwareVersion($v2);
        
        return $v1->compareTo($v2);
    }
356547
def compare_version(v1, v2):
    
    s1 = StrictVersion(v1)
    s2 = StrictVersion(v2)
    if s1 == s2:
        return 0
    elif s1 > s2:
        return -1
    else:
        return 1
908865
public static function Equal ($string1, $string2, $encoding = Encoding::DEFAULT_ENCODING) {
		return (self::Compare($string1, $string2, $encoding) === 0);
	}
831182
public static function compareVersion($v1, $v2)
    {
        if(empty($v1)){
            return 0;
        }

        $l1  = explode('.',$v1);
        $l2  = explode('.',$v2);
        $len = count($l1) > count($l2) ? count($l1): count($l2);

        for ($i = 0; $i < $len; $i++){
            $n1 = isset($l1[$i])?$l1[$i]:0;
            $n2 = isset($l2[$i])?$l2[$i]:0;
            if ($n1 > $n2){
                return true;//需要更新
            }else if ($n1 < $n2){
                return false;//不需要更新
            }
        }
        return false;
    }
203992
public function revisionCompare($revision1, $revision2)
    {
        $revision1 = (int) $revision1;
        $revision2 = (int) $revision2;

        if ($revision1 > $revision2) {
            return 1;
        } elseif ($revision1 < $revision2) {
            return -1;
        } else {
            return 0;
        }
    }
746655
public static function compareElements($elem1, $elem2)
    {
        if (is_array($elem1)) {
            if (is_array($elem2)) {
                return strcmp(serialize($elem1), serialize($elem2));
            }

            return 1;
        }

        if (is_array($elem2)) {
            return -1;
        }

        if ((string)$elem1 === (string)$elem2) {
            return 0;
        }

        return ((string)$elem1 > (string)$elem2) ? 1 : -1;
    }
672211
private static int compare(long v1, long v2) {
		int pos = 0;
		if (v1 != v2) {
			long x = v1 ^ v2;
			pos += Long.numberOfLeadingZeros(x);
			return pos;
		}
		return -1;
	}
1298188
public static int compare( String s1, String s2)
	{
		if (s1 == null && s2 == null)
		{
			return 0;
		}
		else if (s1 == null && s2 != null)
		{
			return -1;
		}
		else if (s1 != null && s2 == null)
		{
			return 1;
		}
		else
		{
			return s1.compareTo(s2);
		}
	}
669390
public function closest(Verta $v1, Verta $v2)
    {
        return $this->diffSeconds($v1) < $this->diffSeconds($v2) ? $v1 : $v2;
    }
1302383
public static function compare(Version $version1, Version $version2)
    {
        if ($version1->toString() == $version2->toString()) {
            return 0;
        }

        $v1 = $version1->getVersionArray();
        $v2 = $version2->getVersionArray();

        if (count($v1) > count($v2)) {
            $v2 = array_pad($v2, count($v1), 0);
        } elseif (count($v1) < count($v2)) {
            $v1 = array_pad($v1, count($v2), 0);
        }

        // version comparison
        foreach ($v1 as $k => $v) {
            if ($v == $v2[$k]) {
                continue;
            }
            if ($v < $v2[$k]) {
                return -1;
            } else {
                return 1;
            }
        }

        // stability comparison
        $s1 = $version1->getStabilityVersion();
        $s2 = $version2->getStabilityVersion();
        if (count($s1) > count($s2)) {
            $s2 = array_pad($s2, count($s1), '');
        } elseif (count($s1) < count($s2)) {
            $s1 = array_pad($s1, count($s2), '');
        }

        foreach ($s1 as $k => $v) {
            if ($v == '*' || $s2[$k] == '*') {
                return 0;
            }
            if ($v === $s2[$k]) {
                continue;
            }
            if ($v === '') {
                if (!is_numeric($s2[$k])) {
                    return 1;
                } else {
                    $v = '0';
                }
            } elseif ($s2[$k] === '') {
                if (!is_numeric($v)) {
                    return -1;
                } else {
                    $s2[$k] = '0';
                }
            }
            if (is_numeric($v)) {
                if (is_numeric($s2[$k])) {
                    $v1 = intval($v);
                    $v2 = intval($s2[$k]);
                    if ($v1 == $v2) {
                        continue;
                    }
                    if ($v1 < $v2) {
                        return -1;
                    }
                    return 1;
                } else {
                    return -1;
                }
            } elseif (is_numeric($s2[$k])) {
                return -1;
            } else {
                if ($v == 'dev' || $v == 'pre') {
                    $v = 'aaaaaaaaaa';
                }
                $v2 = $s2[$k];
                if ($v2 == 'dev' || $v2 == 'pre') {
                    $v2 = 'aaaaaaaaaa';
                }
                $r = strcmp($v, $v2);
                if ($r > 0) {
                    return 1;
                } elseif ($r < 0) {
                    return -1;
                }
            }
        }

        $sv1 = $version1->getSecondaryVersion();
        $sv2 = $version2->getSecondaryVersion();
        if (($sv1 instanceof Version) || ($sv2 instanceof Version)) {
            if (($sv1 instanceof Version) && ($sv2 instanceof Version)) {
                return self::compare($sv1, $sv2);
            }
            else if ($sv1 instanceof Version) {
                return 1;
            }
            else if ($sv2 instanceof Version) {
                return -1;
            }
        }
        return 0;
    }
651918
public static function compare($n1, $n2)
    {
        $n1 = self::round($n1, 2);
        $n2 = self::round($n2, 2);

        return (bccomp($n1, $n2, self::$scale) === 0);
    }
720472
function getVersion()
    {
        if (empty($this->version))
            $this->version = self::Vx1_1;
        
        return $this->version;
    }
929084
public function join($str1 = null, $str2 = null)
    {
        if (is_null($str1)) {
            $str1 = $this->number();
        }
        if (is_null($str2)) {
            $str2 = $this->vn();
        }

        return $str1 . $this->vnSeparator . $str2;
    }
1306834
private function compareHash( $hash1, $hash2 ) {
		$result = strlen( $hash1 ) ^ strlen( $hash2 );
		$len = min( strlen( $hash1 ), strlen( $hash2 ) ) - 1;
		for ( $i = 0; $i < $len; $i++ ) {
			$result |= ord( $hash1{$i} ) ^ ord( $hash2{$i} );
		}
		return $result == 0;
	}
1112300
def compare_versions(version_a, version_b)
      if version_a == version_b
        return 0
      else
        version_a_d = deconstruct_version_string(version_a)
        version_b_d = deconstruct_version_string(version_b)

        if version_a_d[0] > version_b_d[0] ||
          (version_a_d[0] == version_b_d[0] && version_a_d[1] > version_b_d[1]) ||
          (version_a_d[0] == version_b_d[0] && version_a_d[1] == version_b_d[1] && version_a_d[2] > version_b_d[2])
          return 1
        else
          return -1
        end
      end
    end
677980
public function Compare($other)
	{
	    switch ( $other->GetValueCode() )
	    {
	        case SByteProxyFactory::Code:
	            return 0;

	        case ByteProxyFactory::Code:
	        case UShortProxyFactory::Code:
	        case UIntProxyFactory::Code:
	        case ULongProxyFactory::Code:
	        case ShortProxyFactory::Code:
	        case IntProxyFactory::Code:
	        case LongProxyFactory::Code:
	        case IntegerProxyFactory::Code:
	        case DecimalProxyFactory::Code:
	        case FloatProxyFactory::Code:
	        case DoubleProxyFactory::Code:
	            return -1;

	        default:
	            return -2;
	    }
	}
1176394
@Pure
	@Inline(value = "MathUtil.isEpsilonEqual($1, $2, Double.NaN)", imported = {MathUtil.class})
	public static boolean isEpsilonEqual(double v1, double v2) {
		return isEpsilonEqual(v1, v2, Double.NaN);
	}