Home Menu

hexdec

Hexadecimal to decimal

Syntax

hexdec ( string $hex_string ) : number

Parameters

hex_string

The hexadecimal string to convert. Any invalid characters in hex_string are silently ignored.

Hexadecimal Decimal
0 0
1 1
2 2
... ...
7ffffffffffffffe 9223372036854775806
7fffffffffffffff 9223372036854775807 (largest signed integer)
8000000000000000 9223372036854775808
... ...
fffffffffffffffe 18446744073709551614
ffffffffffffffff 18446744073709551615 (largest unsigned integer)

Return

The decimal representation of hex_string

Examples

1

<?

$hex_string1 = "0";
$hex_string2 = "0ghijklmnopqrstuvwxyz";

$return1 = hexdec($hex_string1);
$return2 = hexdec($hex_string2);

echo $return1 . PHP_EOL;
echo $return2;

?>
0
0

2

<?

$hex_string = "1";

$return = hexdec($hex_string);

echo $return;

?>
1

3

<?

$hex_string = "2";

$return = hexdec($hex_string);

echo $return;

?>
2

4

<?

$hex_string = "7ffffffffffffffe";

$return = hexdec($hex_string);

echo $return;

?>
9223372036854775806

5

<?

$hex_string = "7fffffffffffffff";

$return = hexdec($hex_string);

echo $return;

?>
9223372036854775807

6

<?

ini_set("precision", 19);

$hex_string = "8000000000000000";

$return = hexdec($hex_string);

echo $return;

?>
9223372036854775808

7

<?

ini_set("precision", 20);

$hex_string = "fffffffffffffffe";

$return = hexdec($hex_string);

echo $return;

?>
18446744073709551616

8

<?

ini_set("precision", 20);

$hex_string = "ffffffffffffffff";

$return = hexdec($hex_string);

echo $return;

?>
18446744073709551616

PHP

JesusBible
HTMLCSSJSPHPSVGMore
AboutTerms