<分区>
为什么会这样:
printf("%d\n", pow(1,0)); /* outputs 0 */
返回 0
?我预计它会返回 1
。
<分区>
为什么会这样:
printf("%d\n", pow(1,0)); /* outputs 0 */
返回 0
?我预计它会返回 1
。
最佳答案
pow()
返回一个 double
类型。您需要使用 %f
格式说明符来打印 double
。
对提供的参数类型使用不适当的格式说明符会导致 undefined behaviour .检查 C 标准 N1570 (C11
) 的第 §7.21.6.1 章。 (是的,这与 C89
无关,恕我直言)
关于c - pow(1,0) 返回 0?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30669654/