我正在尝试从Steam获取Team Fortress 2项目的decall图像的数据 http://forums.steampowered.com/forums/showthread.php?t=2695676
蒸汽库存物料属性
"attributes": [
{
"defindex": 152,
"value": 160020469,
"float_value": 3.3154542658454145e-033
},
{
"defindex": 227,
"value": 142668139,
"float_value": 7.7604768692394667e-034
},
{
"defindex": 746,
"value": 1065353216,
"float_value": 1
},
{
"defindex": 292,
"value": 1115684864,
"float_value": 64
},
{
"defindex": 388,
"value": 1115684864,
"float_value": 64
}
]
`
function Function_BigDecimal_to_Hexadecimal_Converter($dec) {
$hex = '';
do {
$last = bcmod($dec, 16);
$hex = dechex($last).$hex;
$dec = bcdiv(bcsub($dec, $last), 16);
} while($dec>0);
return $hex;
}
function Function_BigHexadecimal_to_Decimal_Converter($hex) {
$dec = 0; $len = strlen($hex);
for ($i = 1; $i <= $len; $i++) { $dec = bcadd($dec, bcmul(strval(hexdec($hex[$i - 1])), bcpow('16', strval($len - $i)))); }
return $dec;
}
$hex1 = Function_BigDecimal_to_Hexadecimal_Converter('142668139' ); // data from defindex 227
$hex2 = Function_BigDecimal_to_Hexadecimal_Converter('160020469'); // data from defindex 152
echo 'hex1 ',$hex1,'<br>'; // = 880f16b
echo 'hex2 ',$hex2,'<br>'; // = 989b7f5
$hex_append = $hex1.$hex2;
echo 'hex_append ',$hex_append,'<br>'; // = 880f16b989b7f5
$ugcid = Function_BigHexadecimal_to_Decimal_Converter($hex_append);
echo 'ugcid ',$ugcid,'<br>'; // = 38297187109156853
`
预期的ucid值应为612754991346202613
,我得到38297187109156853
这里我正在反转此代码以从预期答案中获取hex_append
echo 'Reversed hex_append using expected answer '.Function_BigDecimal_to_Hexadecimal_Converter('612754991346202613');// = 880f16b0989b7f5
hex_append计算的880f16b989b7f5
与反向回答880f16b0989b7f5
的差异为0
我该如何解决这个问题?
我想有时候在添加2个六角形作为字符串时需要添加一个0
仅在此项目中检测到此问题。
所有这些PHP代码都可以在php文件中复制并执行
答案 0 :(得分:0)
答案:字符串必须包含18个字符