From 05654e20b853fc0cbc50ad34f3f394b5ad570c83 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Wed, 15 Aug 2007 02:48:46 +0000 Subject: For bug #188449, since python floats have limited range, we multiply both floating point representations by a constant so that they are transformed into whole numbers. This allows the practically infinite range of a python int to be exploited. The multiplication is done by padding both literal strings with zeros as necessary to ensure equal length. svn path=/main/trunk/; revision=7606 --- pym/portage/versions.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'pym') diff --git a/pym/portage/versions.py b/pym/portage/versions.py index ebf8cbada..b51b53ae5 100644 --- a/pym/portage/versions.py +++ b/pym/portage/versions.py @@ -98,8 +98,17 @@ def vercmp(ver1, ver2, silent=1): list2.append(int(vlist2[i])) # now we have to use floats so 1.02 compares correctly against 1.1 else: - list1.append(float("0."+vlist1[i])) - list2.append(float("0."+vlist2[i])) + # list1.append(float("0."+vlist1[i])) + # list2.append(float("0."+vlist2[i])) + # Since python floats have limited range, we multiply both + # floating point representations by a constant so that they are + # transformed into whole numbers. This allows the practically + # infinite range of a python int to be exploited. The + # multiplication is done by padding both literal strings with + # zeros as necessary to ensure equal length. + max_len = max(len(vlist1[i]), len(vlist2[i])) + list1.append(int(vlist1[i].ljust(max_len, "0"))) + list2.append(int(vlist2[i].ljust(max_len, "0"))) # and now the final letter if len(match1.group(5)): -- cgit v1.2.3-1-g7c22