## CopyPastehas never been so tasty!

by anonymous

• 0
• 0
• 0
91 views
```Orignal Source:http://codingvilla.com/convert-hexadecimal-decimal-php-single-article-566.aspx
Decimal Values:

Decimal data type is a primitive data type that represents the non-repeating decimal fraction without round-off to apply arithmetic operation on them.
Decimal values are represented as fixed point value.
For example:

\$Value=0.3; \$Value2=255;

Hexadecimal is base-16 number system with a radix or a base. Hexadecimal uses 16 distinct symbols for representation. 0-9 using for zero to nine and A, B, C… are used for next number 10, 11, 12…
For example:

\$Value=9; \$Value2=ff;

Convert decimal number into hexadecimal using dechex() function in php:

To convert decimal number into hexadecimal php supports built in function name as dechex() function

This function takes decimal value as a parameter and returns a hexadecimal converted number.

Code:

<?php
\$orig_dec = 255;
\$dec2hex = dechex(\$orig_dec);
echo "original decimal number: \$orig_dec <br>";
echo "new hexadecimal number: \$dec2hex <br>";
?>

This is simple code to convert decimal number into hexadecimal number using dechex() function.

Convert Hexadecimal number into decimal using hexdec() function in php:

To convert hexadecimal number into decimal php supports built in function name as hexdec() function

This function takes hexadecimal value as a parameter and returns a decimal converted value.

Code:

<?php
\$orig_hex = ff;
\$hex2dec = hexdec(\$orig_dec);
echo "original hexadecimal number: \$orig_dec <br>";
echo "New converted decimal number is: \$hex2dec <br>";
?>

This is a simple code to convert decimal number into hexadecimal number using hexdec() function.

This simple article tells that how we can convert decimal number into hexadecimal number using dechex() function and hexadecimal to decimal number using hexdec() function in PHP.
```