r2196 - IPv4NetworkCmp(): use BC math
authorDenis Ovsienko <infrastation@yandex.ru>
Thu, 4 Sep 2008 13:42:03 +0000 (13:42 +0000)
committerDenis Ovsienko <infrastation@yandex.ru>
Thu, 4 Sep 2008 13:42:03 +0000 (13:42 +0000)
inc/functions.php

index 6e19b26503e05e5d7c438071ad729753c59a1c03..c714dfad152c14451577a20cd0688761cf220885 100644 (file)
@@ -1417,15 +1417,7 @@ function taginfoCmp ($tagA, $tagB)
 // distinct base IP addresses.
 function IPv4NetworkCmp ($netA, $netB)
 {
-       // There's a problem just substracting one u32 integer from another,
-       // because the result may happen big enough to become a negative i32
-       // integer itself (PHP tries to cast everything it sees to signed int).
-       if ($netA['db_first'] > $netB['db_first'])
-               return 1;
-       elseif ($netA['db_first'] < $netB['db_first'])
-               return -1;
-       else
-               return 0;
+       return bccomp ("${netA['db_first']}", "${netB['db_first']}");
 }
 
 // Modify the given tag tree so, that each level's items are sorted alphabetically.