作者热门文章
- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我如何转换它:
9312660682897061594767289296453011313180604726492752614962349778735928598708212386406555876878916185094145420038141655929349984786756296776268556142401047
以 16 进制?
我找到了这个递归函数:
function bcdechex($dec) {
$last = bcmod($dec, 16);
$remain = bcdiv(bcsub($dec, $last), 16);
if($remain == 0) {
return dechex($last);
} else {
return bcdechex($remain).dechex($last);
}
}
但嵌套级别已达到 100,即使我的 php.ini 配置文件中有 xdebug.max_nesting_level = 1000。
我的 xdebug 配置如下所示:
;Xdebug
zend_extension = "${path}\php\php546x121216181946\php_xdebug-2.2.1-5.4-vc9.dll"
xdebug.default_enable=1
xdebug.remote_enable=1
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_autostart = false
xdebug.dump_globals=1
xdebug.dump=COOKIE,FILES,GET,POST,REQUEST,SERVER,SESSION
xdebug.dump.SERVER=REMOTE_ADDR,REQUEST_METHOD,REQUEST_URI
xdebug.show_local_vars=1
xdebug.show_mem_delta=1
xdebug.collect_includes=1
xdebug.collect_vars=1
xdebug.collect_params=4
xdebug.collect_return=1
xdebug.auto_trace=0
xdebug.trace_options=0
xdebug.trace_format=0
xdebug.trace_output_dir="${path}\xdebug\trace"
xdebug.trace_output_name="trace.%t"
xdebug.profiler_enable=0
xdebug.profiler_append=1
xdebug.profiler_enable_trigger=1
xdebug.profiler_output_dir="${path}\xdebug\profiler"
xdebug.profiler_output_name="cachegrind.out.%s.%t"
xdebug.max_nesting_level = 1000
;/Xdebug
是否有人拥有与此不同的功能或关于如何转换此整数的任何提示?
谢谢你!
最佳答案
修改您发现的迭代函数而不是递归函数非常容易:
function bcdechex($dec) {
$hex = '';
do {
$last = bcmod($dec, 16);
$hex = dechex($last).$hex;
$dec = bcdiv(bcsub($dec, $last), 16);
} while($dec>0);
return $hex;
}
您的示例 $bignum
转换为十六进制是:b1cf5653e79bef001acfb0f99d1f34487d16a8253e3a9971e98d46382114e8ac81b5102ab3c56be1f77d0eb754f566c0dacb23d64755e823f35411f9e14c5617>
关于php - 如何在 php 中将一个巨大的整数转换为十六进制?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14539727/
我是一名优秀的程序员,十分优秀!