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

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

问题描述

尝试很多,只是失败了.

Trying a lot and just failing..

$x = 76561198005785475;

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

I want to this number, turn into this:

$y = 45519747;

这是它的32位形式.

尝试解释更多细节:

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

1)将值76561198005785475放入十进制(输入)"字段. 2)在二进制(基本2)"字段上按"DEC to BIN". 3)从右边开始计数32,然后复制它. 4)在二进制(基数2)"字段上粘贴32个字符的二进制数. 5)在二进制(基数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天全站免登陆