示例#1
0
 public static function num2str($num)
 {
     switch (BigInt::support()) {
         case 'gmp':
             $str = gmp_strval($num, 16);
             $len = strlen($str);
             if ($len % 2 == 1) {
                 $str = '0' . $str;
             }
             return pack("H*", $str);
         case 'big_int':
             $str = bi_to_str($num, 16);
             $len = strlen($str);
             if ($len % 2 == 1) {
                 $str = '0' . $str;
             }
             return pack("H*", $str);
         case 'bcmath':
             bcscale(0);
             $str = "";
             while (bccomp($num, '0') == 1) {
                 $str = chr(bcmod($num, '256')) . $str;
                 $num = bcdiv($num, '256');
             }
             return $str;
         case '':
         default:
             return BigInt::_num2str($num);
     }
 }