Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
gdb不将sqrt(-1.0)打印为NaN_Gdb - Fatal编程技术网

gdb不将sqrt(-1.0)打印为NaN

gdb不将sqrt(-1.0)打印为NaN,gdb,Gdb,我检查了sqrt(-1.0)是否返回NaN()。在gdb中,它不返回NaN (gdb) p/x sqrt(-1.0) $10 = 0xe53a86a0 (gdb) p sqrt(-1.0) $11 = -449149280 GDB调用不同的sqrt吗?我使用的是GDB7.6,看起来gdb无法访问合适的调试信息。因此,它假定sqrt是一个返回int的函数: (gdb) ptype sqrt type = int () 您可以使用强制转换告诉GDB正确的类型: (gdb) print ((dou

我检查了sqrt(-1.0)是否返回NaN()。在gdb中,它不返回NaN

(gdb) p/x sqrt(-1.0)
$10 = 0xe53a86a0
(gdb) p sqrt(-1.0)
$11 = -449149280

GDB调用不同的sqrt吗?我使用的是GDB7.6,看起来gdb无法访问合适的调试信息。因此,它假定
sqrt
是一个返回
int
的函数:

(gdb) ptype sqrt
type = int ()
您可以使用强制转换告诉GDB正确的类型:

(gdb) print ((double (*)(double))sqrt)(2)
$1 = 1.4142135623730951

或者您可以加载合适的调试信息。

虽然我用复制了帖子,但该帖子上接受的答案(使用_sqrt)对-1.0不起作用:它返回-165394784。弗洛里安·魏默的回答对我很有用。