从 64 位数字转换为 32 位数字 [英] Convert from 64bit number to 32bit number

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

问题描述

尝试了很多,但都失败了..

Trying a lot and just failing..

$x = 76561198005785475;

我要这个号码,变成这个:

I want to this number, turn into this:

$y = 45519747;

这是它的 32 位形式.

That is the 32bit form of it.

试图解释更多细节:

http://www.tonymarston.net/php-mysql/converter.php

1) 将值 76561198005785475 放在十进制(输入)"字段中.2) 在Binary (Base 2)"字段上按DEC to BIN".3)从右边开始数32并复制它.4) 将 32 个字符的二进制数粘贴到Binary (Base 2)"字段上.5) 在Binary (Base 2)"字段上按Bin to Dec"按钮.

1) Put the value 76561198005785475 on the "Decimal (input)" field. 2) Press "DEC to BIN" on the "Binary (Base 2)" field. 3) Count 32 starting from the RIGHT and copy it. 4) Paste the 32 chars binary number on "Binary (Base 2)" field. 5) Press "Bin to Dec" button on the "Binary (Base 2)" field.

好的,现在您可以看到45519747"号码了.

Ok, now you can see the "45519747" number.

推荐答案

试试这个:

$y = $x & 0xffffffff;

这会将您的 64 位值截断为 32 位值,但请注意,绝对无法恢复 64 位值,这是一种破坏性方法.

This will truncate your 64-bit value to a 32-bit value, but note that there is absolutely no way to get the 64-bit value back, this is a destructive method.

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

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