Pergunta

Estou tendo problemas com essa equação ficando-lo para retornar o valor correto.De acordo com o Vapor, a equação Steam_community_number = (Last_part_of_steam_id * 2) + 76561197960265728 + Second_to_last_part_of_steam_id Deve retornar a versão de 64 bits da Comunidade Steam ID.Atualmente, esta equação está voltando 7.6561198012096E+16.A equação deve estar voltando 76561198012095632 o que de certa forma é quase a mesma que ele já está voltando.Como posso converter os retornados E+16 valor para o valor correto, conforme indicado acima no meu código abaixo?Obrigado.

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;
}

E eu estou chamando esta função com $cid = convertSID("STEAM_0:0:25914952");

Se você gostaria de ver um exemplo de saída, confira aqui: http://joshua-ferrara.com/hkggateway/sidtester.php

Foi útil?

Solução

Mudança

return (string)$cid;

para

return number_format($cid,0,'.','');

Esteja ciente de que isso irá retornar uma seqüência de caracteres, e se você fizer qualquer de matemática, ele será convertido para float.Para fazer matemática em grandes números inteiros de uso bc_math extensão: http://www.php.net/manual/en/book.bc.php

editar:sua função convertido para usar bcmath:

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

    $steamidExploded = explode(':',$steamid);
    $Y = (int)steamidExploded[1];
    $Z = (int)steamidExploded[2];
    echo "Z: " . $Z . "</br>";
    $cid = bcadd('76561197960265728 ',$Z * 2 + $Y);
    echo "Equation: (" . $Z . " * 2) + 76561197960265728 + " . $Y . "<br/>";
    return $cid;
}
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top