在我的Linux机器上,计算一个大于flt_max的浮点值会导致无穷大,如下所示:

sacha@sacha-XPS13:~$ gdb
GNU gdb (GDB) 7.6.1-ubuntu
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
(gdb) p 1e39f
$1 = inf
(gdb)

问:为什么使用android ndk时不一样?如下图所示,它环绕而不是返回无穷大:
sacha@sacha-XPS13:~$ ~/lib/android-ndk-r9d/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gdb
GNU gdb (GDB) 7.3.1-gg2
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=x86_64-linux-gnu --target=arm-linux-android".
For bug reporting instructions, please see:
<http://source.android.com/source/report-bugs.html>.
(gdb) p 1e39f
$1 = -5.5173927e-39
(gdb)

最佳答案

7.6之前的gdb股票也有同样的问题,直到它被这个patch修正。跟踪ndk中gdb-7.3.x中的修复here

关于android - 为什么在Android NDK上,大于FLT_MAX的float不是无限的?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/23401170/

10-10 20:02