Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert from 64bit number to 32bit number

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.

like image 321
Otuyh Avatar asked Jul 27 '12 16:07

Otuyh


People also ask

How can I convert 64-bit to 32-bit?

You can't. There's no way to change the "bitness" of any version of Windows from 32-bit to 64-bit, or vice versa.

How do I change from 64bit to 32bit Windows 7?

1) Right click on the Program 2) Click on Properties3) Click on Compatibility tab4) Select Run this program in compatibility mode and select Windows Vista or another operating system the program was running successfully.

What is the difference between 32-bit and 64-bit integer?

A 32 bit Signed Integer can house a number from −2,147,483,648 to 2,147,483,647 Unsigned: 0 to 4,294,967,295. A 64 bit Signed Integer can house a number from −9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 Unsigned: 0 to 18,446,744,073,709,551,615.


1 Answers

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.

like image 57
Niet the Dark Absol Avatar answered Sep 28 '22 05:09

Niet the Dark Absol