note 25591 added to function.dechex

From: Date: Sun, 29 Sep 2002 19:12:28 +0000
Subject: note 25591 added to function.dechex
Groups: php.notes 
Request: Send a blank email to php-notes+get-37395@lists.php.net to get a copy of this message
<? function dec2hex($number) { $length=16; $hexval=""; while ($number>0) { $remainder=bcmod($number,16); if ($remainder<10) $hexval=$remainder.$hexval; elseif ($remainder==10) $hexval="A".$hexval; elseif ($remainder==11) $hexval="B".$hexval; elseif ($remainder==12) $hexval="C".$hexval; elseif ($remainder==13) $hexval="D".$hexval; elseif ($remainder==14) $hexval="E".$hexval; elseif ($remainder==15) $hexval="F".$hexval; $number=bcdiv($number,16); } while (strlen($hexval)<$length) $hexval="0".$hexval; return $hexval; } $tmp = "<table width='643' border='1'>"; $x = 1; $y = 1; $z = dec2hex($x); $q = dec2hex($y); for ($i=1;$i<65;$i++){ $x= bcpow(2,($i-1)); $z = dec2hex($x); $tmp .="<tr><td width='20' align='center' bgcolor='#808080'><font color='#ffffff'>". $i; $tmp .="</font></td><td width='5'>2<sup>". ($i-1) . "</sup></td><td width='2'>=</td></td><td>" . $x . "</td>"; $tmp .="<td>".$z."</td><td>".$y."</td><td>".$q."</td></tr>"; $y = bcsub(bcpow(2,$i+1),1); $q = dec2hex($y); } $tmp .= "</table>"; echo $tmp; ?> -- http://www.php.net/manual/en/function.dechex.php http://master.php.net/manage/user-notes.php?action=edit+25591 http://master.php.net/manage/user-notes.php?action=delete+25591 http://master.php.net/manage/user-notes.php?action=reject+25591

« previous php.notes (#37395) next »