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

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

问题描述

所以我正在使用 PHP 来转换 Steam Id,你们中的许多人可能都很熟悉.我有以下 Steam 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.在此处浏览 Steams 官方发布后: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

原来如此!但是,我的实际社区 ID 与我生成的社区 ID 之间似乎不匹配

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

逆方程时,要从社区 ID 中获取我的 Steam 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

我做错了吗?

推荐答案

PHP 在 32 位二进制文​​件上没有 64 位 int.它在这里使用浮点数.请参阅如何在 PHP 上使用 64 位整数?

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 Math的链接,可以是用于解决您的问题.

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

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

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