private static function Database::bcBin2Dec in Smart IP 7.2
Same name and namespace in other branches
- 6.2 includes/vendor/ip2location/ip2location-php/IP2Location.php \IP2Location\Database::bcBin2Dec()
Return the decimal string representing the binary data given
@access private @static
Parameters
string $data Binary data to parse:
Return value
string
1 call to Database::bcBin2Dec()
- Database::readQuad in includes/
vendor/ ip2location/ ip2location-php/ IP2Location.php - Low level function to fetch a quadword (128 bits) from the caching backend
File
- includes/
vendor/ ip2location/ ip2location-php/ IP2Location.php, line 1010
Class
- Database
- IP2Location database class
Namespace
IP2LocationCode
private static function bcBin2Dec($data) {
$parts = array(
unpack('V', substr($data, 12, 4)),
unpack('V', substr($data, 8, 4)),
unpack('V', substr($data, 4, 4)),
unpack('V', substr($data, 0, 4)),
);
foreach ($parts as &$part) {
if ($part[1] < 0) {
$part[1] += 4294967296;
}
}
$result = bcadd(bcadd(bcmul($parts[0][1], bcpow(4294967296, 3)), bcmul($parts[1][1], bcpow(4294967296, 2))), bcadd(bcmul($parts[2][1], 4294967296), $parts[3][1]));
return $result;
}