note 99257 added to function.dechex
| From: | J dot M dot vanLeeuwen at osu1 dot php dot net | Date: | Fri, 06 Aug 2010 10:05:13 +0000 |
| Subject: | note 99257 added to function.dechex | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-171423@lists.php.net to get a copy of this message | ||
Here's another solution to 'extend' dechex's size limitation. This supports also
values > 2.147.483.648, but doesn't support signs because I only used positive numbers in
the script where I used this function.
function
dec2hex($dec,$hex=array(0,1,2,3,4,5,6,7,8,9,'a','b','c','d','e','f')){
for($h='',$r=$dec;$r>15;){
// $r%16 is inaccurate when using bigger values, like 11.435.168.214!
$n = floor($r/16); $h = $hex[($r-$n*16)].$h; $r = $n;
}
return $hex[($r%16)].$h;
}
----
Server IP: 69.147.83.197
Probable Submitter: 145.99.174.241
----
Manual Page -- http://www.php.net/manual/en/function.dechex.php
Edit -- https://master.php.net/note/edit/99257
Del: integrated -- https://master.php.net/note/delete/99257/integrated
Del: useless -- https://master.php.net/note/delete/99257/useless
Del: bad code -- https://master.php.net/note/delete/99257/bad+code
Del: spam -- https://master.php.net/note/delete/99257/spam
Del: non-english -- https://master.php.net/note/delete/99257/non-english
Del: in docs -- https://master.php.net/note/delete/99257/in+docs
Del: other reasons-- https://master.php.net/note/delete/99257
Reject -- https://master.php.net/note/reject/99257
Search -- https://master.php.net/manage/user-notes.php