How to convert hexadecimal to floating point number in php: 1. Use the "hexdec (hexadecimal value)" or "base_convert (hexadecimal value, 16,10)" statement to convert hexadecimal to floating point number. Convert the system value to a decimal number; 2. Use the "floatval (decimal number)" statement to obtain the floating point value and convert the decimal number to a floating point number type.
The operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
php will enter 16 Method to convert system to floating point number
Implementation idea:
Convert hexadecimal value to decimal number---Function:hexdec(hexdecimal value)
orbase_convert(hexdecimal value,16,10)
function
hexdec() function is specially used for hexadecimal values Convert to decimal number, and the bindec() function can convert numbers between any bases
Convert decimal number to floating point number--Function floatval()
The floatval function is used to get the floating point value of a variable.
Implementation example:
<?php $hex = "cceeff"; $num1=hexdec($hex); $num2=base_convert($hex, 16, 10); $float1=floatval($num1); $float2=floatval($num2); var_dump($float1); var_dump($float2); ?>
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of How to convert hexadecimal to floating point number in php. For more information, please follow other related articles on the PHP Chinese website!