<BR>//取进制位上的数值 <BR>function getRemainder($num, $bin, $pos, &$result = 0){ <BR>//author lianq.net <BR>//$num 数值,十进制 <BR>//$bin 要转换的进制 <BR>//$pos 位数 <BR>$real_len = log($num, $bin);//对数,求原值长度 <BR>$floor_len = floor<mark>6来源gaodaimacom搞#^代%!码网</mark><strong>搞gaodaima代码</strong>($real_len);//舍去求整 <BR>$base = pow($bin, $pos-1);//基数 <BR>$divisor = pow($bin,$pos);//除数 <BR>if($num >= $divisor){ <BR>$new_num = $num % pow($bin, $floor_len); <BR>getRemainder($new_num, $bin, $pos, $result); <BR>}else{ <BR>$result = floor($num / $base); <BR>} <BR>return $result; <BR>} <br><br>//比如,数值16转换为9进制时,它的第一位上的数值是多少? <BR>$a = getRemainder(16,9, 1); <BR>echo $a;//输出7 <BR>