Convert a hexadecimal value to a decimal integer.

Source: Internet
Author: User
How do I convert hexadecimal to a 10-digit integer dual-byte hexadecimal to a decimal form?
For example: 0 xFFFFFFBF;
The hexdec function is converted to 4 bytes.


Reply to discussion (solution)

$ S = 0 xFFFFFFBF; echo $ s; // 4294967231 $ s = 'ffffffbf'; echo hexdec ($ s); // 4294967231

I don't know what you want to do?
In your example, the data is 4 bytes.

Or does this mean?
$ N = 0 xFFFFFFBF; $ s = pack ('L', $ n); echo bin2hex ($ s), PHP_EOL; print_r (unpack ('n *', $ s ));
Bfffffff
Array
(
[1] => 49151.
[2] => 65535.
)

This value should be converted to-65, and the weak php type will be automatically processed as a long integer.

$ N = 0 xFFFFFFBF; $ s = pack ('L', $ n); print_r (unpack ('L', $ s ));
Array
(
[1] =>-65
)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.