Php hexadecimal transformation

Source: Internet
Author: User
Tags binary to decimal decimal to binary
Php hexadecimal conversion 1. decimal 1. decimal to binary decbin () function: returns a string containing the binary representation of the given number parameter. The maximum number that can be converted & #20540; is 4294967295 in decimal format, and the result is a string of 32 and 1. 2. Convert decimal to octal de php hexadecimal conversion

1. decimal

1. decimal to binary decbin () function: returns a string containing the binary representation of the given number parameter. The maximum value to be converted is 4294967295 in decimal format, and the result is a string of 32 characters.

2. decimal to octal decoct () function: returns a string containing the octal representation of the given number parameter. The maximum value to be converted is 4294967295 in decimal format, and the result is 37777777777 ".

3. decimal to hexadecimal dechex () function: returns a string containing the hexadecimal representation of the given number parameter. The maximum value to be converted is 4294967295 in decimal format, and the result is "ffffffff ".

 

II. binary

1. binary to hexadecimal bin2hex () function: returns an ASCII string, which is the hexadecimal representation of the str parameter. The byte mode is used for conversion. the byte level is higher than the byte level.

2. Convert binary to decimal to bindec () function: bindec () converts a binary number to an integer. The maximum number of convertible values is 31-bit 1 or decimal 2147483647. PHP 4.1.0 starts. This function can process large numbers. in this case, it returns the float type.

 

III. Gossip

Octal to decimal Dec () function: returns the decimal equivalent of the octal value represented by the octal_string parameter. The maximum convertible value is 17777777777 or 2147483647 in decimal format. PHP 4.1.0 starts. This function can process large numbers. in this case, it returns the float type.

 

IV. hexadecimal

Hexadecimal to decimal hexdec () function: returns the decimal number equivalent to the hexadecimal number indicated by the hex_string parameter. Hexdec () converts a hexadecimal string to a decimal number. The maximum value to be converted is 7 fffffff, that is, 2147483647 of the decimal number. PHP 4.1.0 starts. This function can process large numbers. in this case, it returns the float type.
Hexdec () replaces all non-hexadecimal characters with 0. In this way, all the zeros on the left are ignored, but the zeros on the right are included.

 

5. Any hexadecimal conversion base_convert () function

Base_convert -- convert a number between any hexadecimal notation: returns a string containing the number in tobase notation. The number is specified by frombase in hexadecimal notation. Both frombase and tobase can only be between 2 and 36 (including 2 and 36 ). Numbers higher than decimal digits are represented by the letter a-z. for example, a represents 10, B represents 11, and z represents 35.

Eg.

$ Hexadecimal = 'a37334 ';
Echo base_convert ($ hexadecimal, 16, 2); // output 101000110111001100110100


 

 

 

 

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.