Home > Backend Development > PHP Problem > How to convert hexadecimal to floating point number in php

How to convert hexadecimal to floating point number in php

青灯夜游
Release: 2023-03-15 19:58:02
Original
3239 people have browsed it

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.

How to convert hexadecimal to floating point number in php

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);
?>
Copy after login

How to convert hexadecimal to floating point number in php

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!

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template