Convert from 64bit number to 32bit number

前端 未结 3 1916
我寻月下人不归
我寻月下人不归 2020-12-07 02:46

Trying a lot and just failing..

$x = 76561198005785475;

I want to this number, turn into this:

$y = 45519747;
3条回答
  •  不知归路
    2020-12-07 03:13

    Try this:

    $y = $x & 0xffffffff;
    

    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.

提交回复
热议问题