GDB能正确解析C风格的十六进制浮点数吗?

GDB能正确解析C风格的十六进制浮点数吗?,c,floating-point,gdb,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 c

我无法使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
GNU gdb(Ubuntu 7.7.1-0ubuntu5~14.04.2)7.7.1
版权所有(C)2014免费软件基金会。
许可证GPLv3+:GNU GPL版本3或更高版本
这是自由软件:您可以自由更改和重新发布它。
在法律允许的范围内,不存在任何担保。键入“显示复制”
和“显示保修”了解详细信息。
此GDB配置为“x86_64-linux-gnu”。
键入“显示配置”以获取配置详细信息。
有关错误报告说明,请参阅:
.
在线查找GDB手册和其他文档资源,网址为:
.
要获得帮助,请键入“帮助”。
键入“apropos word”搜索与“word”相关的命令。
(gdb)p 0xa.0p-4
$1 = 6
这里的
$1
应该是
0.625
,但我的GDB似乎将
0xa.0p
视为十进制
10
,并对
-4
进行后续添加。 我要求GDB打印的内容有什么问题? 我找不到任何关于GDB如何处理十六进制浮点的相关文档

我要求GDB打印的内容有什么问题

显然这是gdb的一个bug

具有负指数的十六进制浮点常量在gdb中给出错误的结果

我在Linux上尝试了最新的源代码版本gdb 7.9(2015年2月20日),支持正指数的十六进制浮点常量:

(gdb) p/f 0x00.1p0
$1 = 0.0625
(gdb) p/f 0x00.1p1
$2 = 0.125
但如果指数为负,则结果是错误的:

(gdb) p/f 0x00.1p-1
$3 = -0.9375

正确的和预期的结果是
0.031250

@hdl我在gdb Bugzilla上找不到任何打开的bug您想打开一个吗?否则我可以自己归档。对于
无效数字
错误,请参阅@hdl good point,我删除了我答案中的这一点以避免不必要的噪音。我也可以。如果您已经拥有Sourceware Bugzilla帐户,请归档并在此处报告。否则我能做到谢谢,我还根据向Ubuntu报告了它