Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Trying a lot and just failing..

$x = 76561198005785475;

I want to this number, turn into this:

$y = 45519747;

That is the 32bit form of it.


Trying to explain with more details:

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

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.

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
199 views
Welcome To Ask or Share your Answers For Others

1 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...