Copy the code The code is as follows:
//Get the value in the base digit
function getRemainder($num, $bin, $pos, &$result = 0){
//author lianq.net
//$num value, decimal
//$bin The base to be converted
//$pos number of digits
$real_len = log($num, $bin);//Logarithm, find the length of the original value
$floor_len = floor($real_len);//Truncate to integer
$base = pow($bin, $pos-1);//Base number
$divisor = pow($bin,$pos);//Divisor
if($ num >= $divisor){
$new_num = $num % pow($bin, $floor_len);
getRemainder($new_num, $bin, $pos, $result);
}else{
$result = floor( $num / $base);
}
return $result;
}
//For example, when the value 16 is converted to base 9, what is the first digit of it?
$a = getRemainder(16,9, 1);
echo $a;//Output 7
The above has introduced the 0x00000050 computer blue screen code and the PHP remainder function code, including the 0x00000050 computer blue screen code. I hope it will be helpful to friends who are interested in PHP tutorials.