为什么在Android NDK上浮动大于FLT_MAX而不是无限?

时间:2014-05-01 02:25:45

标签: android android-ndk

在我的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) 

1 个答案:

答案 0 :(得分:1)

7.6之前的股票gdb具有相同的问题,直到由此patch修复。已跟踪NDK中的gdb-7.3.x中的修复here