*
* static int numToInt(String $numeric)
* returns the integer value, the numeric represents
+ *
+ * static String parseIP(String $numeric)
+ * parses an IP Address in numeric format
+ *
+ * static String numericFromIP(String $ip)
+ * builds a numeric representing the IP
*/
class Numerics {
private static $base64charsLength = 64;
public static function intToNum($int, $length) {
- //fix a small "bug": normaly 0 = AAAAA but we need 1 = AAAAA
- $int = $int - 1;
-
$numeric = "";
for($pos = $length-1; $pos >= 0; $pos--) {
//current position represents floor($int / ($base64charsLength ^ $pos))
$int = ($posValue * $base);
$base = $base * self::$base64charsLength;
}
-
- //fix a small "bug": normaly 0 = AAAAA but we need 1 = AAAAA
- $int = $int + 1;
-
return $int;
}