我在使這個公式返回正確的值時遇到了麻煩。根據Steam,等式Steam_community_number = (Last_part_of_steam_id * 2) + 76561197960265728 + Second_to_last_part_of_steam_id
應返回64位Steam社區ID。目前,該等式正在返回7.6561198012096E+16
。該公式應該返回76561198012095632
,這在某種程度上與它已經返回的方式幾乎相同。我如何將返回的E + 16值轉換爲以上代碼中所述的正確值?謝謝。PHP數學公式,E + 16?
function convertSID($steamid) {
if ($steamid == null) { return false; }
//STEAM_X:Y:Z
//W=Z*2+V+Y
//Z, V, Y
//Steam_community_number = (Last_part_of_steam_id * 2) + 76561197960265728 + Second_to_last_part_of_steam_id
if (strpos($steamid, ":1:")) {
$Y = 1;
} else {
$Y = 0;
}
$Z = substr($steamid, 10);
$Z = (int)$Z;
echo "Z: " . $Z . "</br>";
$cid = ($Z * 2) + 76561197960265728 + $Y;
echo "Equation: (" . $Z . " * 2) + 76561197960265728 + " . $Y . "<br/>";
return (string)$cid;
}
我打電話來與$cid = convertSID("STEAM_0:0:25914952");
這個功能如果你想看到的輸出的一個例子,檢查這裏:http://joshua-ferrara.com/hkggateway/sidtester.php
相關:要在大的整數使用
bc_math
擴展做數學[如何對PHP 64位整數?](HTTP://計算器。 com/questions/864058/how-to-have-64-bit-integer-on-php) – Orbling 2012-03-01 17:18:06