note 12096 deleted from function.dechex by felipe
| From: | felipe@php.net | Date: | Sat, 29 Dec 2007 20:35:52 +0000 |
| Subject: | note 12096 deleted from function.dechex by felipe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-134203@lists.php.net to get a copy of this message | ||
Note Submitter:
----
# dec2hex function
#
# For hex numbers that go up to FFFFFFFF (instead of 7FFFFFFF)
#
# crude but does the job...
#
function dec2hex($dec)
{
if($dec > 2147483648)
{
$result = dechex($dec - 2147483648);
$prefix = dechex($dec / 268435456);
$suffix = substr($result,-7);
$hex = $prefix.str_pad($suffix, 7, "0000000", STR_PAD_LEFT);
}
else
{
$hex = dechex($dec);
}
return($hex);
}