hdl*_*hdl 6 c floating-point gdb
我无法使GDB正确打印一些C风格的十六进制浮点数,请参阅:
GNU gdb (Ubuntu 7.7.1-0ubuntu5~14.04.2) 7.7.1
Copyright (C) 2014 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".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
(gdb) p 0xa.0p-4
$1 = 6
Run Code Online (Sandbox Code Playgroud)
这$1应该是,0.625但我的GDB似乎0xa.0p看作十进制10,并随后添加-4.我要求GDB打印出什么问题?我找不到任何关于GDB如何处理十六进制浮点数的相关文档.
我要求 GDB 打印的内容有什么问题?
显然这是 gdb 的一个错误。
具有负指数的十六进制浮点常量会在 gdb 中给出错误的结果。
我尝试在 Linux 上使用最新的源代码版本 gdb 7.9(2015 年 2 月 20 日),并且支持具有正指数的十六进制浮点常量:
(gdb) p/f 0x00.1p0
$1 = 0.0625
(gdb) p/f 0x00.1p1
$2 = 0.125
Run Code Online (Sandbox Code Playgroud)
但如果指数为负数,则结果错误:
(gdb) p/f 0x00.1p-1
$3 = -0.9375
Run Code Online (Sandbox Code Playgroud)
正确且预期的结果是0.031250。