Hexadecimal is a positional numeral system with a base of 16. It has sixteen distinct symbols, where the first nine symbols are 0–9 which represent values zero to nine, and the rest 6 symbols are A, B, C, D, E, F which represent values from ten to fifteen respectively. Since hexadecimal digit represents four binary digits, it allows a more human-friendly representation of binary-coded values and hence it is preferred over other number systems like binary and octal.
The hexdec() function in PHP converts a hexadecimal number to a decimal number.
The hexdec() function converts numbers that are too large to fit into the integer type, larger values are returned as a float in that case. If hexdec() encounters any non-hexadecimal characters, it ignores them.
Parameters: The hexdec() function accepts a single parameter $value. It is the hexadecimal number whose decimal equivalent you want to calculate.
Return Value: The hexdec() function in PHP returns the decimal equivalent of a hexadecimal number.
Input : hexdec("5e") Output : 94 Input : hexdec("a") Output : 10 Input : hexdec("f1f1") Output : 61937 Input : hexdec("abc451") Output : 11256913
Below program illustrate the working of hexdec() in PHP:
94 10 61937 11256913
Important points to note :
- It converts a hexadecimal number to its decimal equivalent.
- It returns the values as float if the numbers are too large to be returned as integer type .
- The hexadecimal number system is one of the most popular and widely used number system these days.
- How to get the function name inside a function in PHP ?
- CSS | rgb() Function
- D3.js | d3.map.set() Function
- p5.js | box() Function
- D3.js | d3.min() function
- PHP | max( ) Function
- PHP | Ds\Map get() Function
- PHP | min( ) Function
- PHP | Ds\Map last() Function
- D3.js | d3.hcl() Function
- p5.js | value() Function
- D3.js | d3.rgb() Function
- p5.js | int() function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.