转换为64位整型 [英] Conversion to 64 bit int

查看:169
本文介绍了转换为64位整型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我在PHP我的工作来转换蒸汽标识,其中有许多你可能很熟悉。我有以下的蒸汽ID:

So I am working in PHP to convert a Steam Id, which many of you may be familiar with. I have the following steam ID:

STEAM_0:1:1514332

现在,我需要将其转换为64位版本,这也是社区ID。经过浏览蒸煮这个位置正式发布: http://developer.valvesoftware.com/wiki/SteamID后也找网上很多地方,我发现下面的方法适用于这样的:

Now, I need to convert this to the 64 bit version, which is also the community ID. After browsing Steams official release on this here: http://developer.valvesoftware.com/wiki/SteamID and after also looking many places online, I have found the following method works for this:

Let X,Y, and Z be defined by the Steam ID: STEAM_X:Y:Z
SteamCommunityID = (Z*2) + 76561197960265728 + Y

所以它的工作原理!然而,在似乎是我的实际的社区标识之间的不匹配,和一个我产生

So it works! However, where seems to be a mismatch between my ACTUAL community ID, and the one I am generating

Actual:        76561197963294393
PHP generated: 76561197963294000

在倒车equasion,从社会的ID让我的蒸汽编号,我得到: 1514335.5

When reversing the equasion, to get my steam id from the community id, I get: 1514335.5

下面是有问题的PHP的一个简单的例子:

Here is a simple example of the php in question:

//STEAM_0:1:1514332

$a = (1514332 * 2) + 76561197960265728 + 1;
echo $a; //76561197963294000

我是不是做错了什么?

Am I doing something wrong?

推荐答案

PHP没有对32位二进制64位的int。它是这里使用浮点。看到如何有64位整数的PHP?

PHP don't have 64bit int on 32-bit binary. It is using floating point here. see how to have 64 bit integer on PHP?

问题包括指向 BC数学,它可以用来针对您的问题。

The question include links to BC Math, which can be used for your problem.

这篇关于转换为64位整型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆