HomeMenu
Jesus · Bible · HTML · CSS · JS · PHP · SVG · Applications

hexdec

Description

The hexdec of Math for PHP 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.

HexadecimalDecimal
00
11
22
......
7ffffffffffffffe9223372036854775806
7fffffffffffffff9223372036854775807 (largest signed integer)
80000000000000009223372036854775808
......
fffffffffffffffe18446744073709551614
ffffffffffffffff18446744073709551615 (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