POW()转换为整数时,意想不到的结果 [英] pow() cast to integer, unexpected result

查看:228
本文介绍了POW()转换为整数时,意想不到的结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用在C编程语言中的 POW()函数整数投一些问题。我使用的编译器是Windows平台上微小的C编译器(TCC版本0.9.24)。当执行以下code,它输出意想不到的结果 100,99

I have some problems using an integer cast for the pow() function in the C programming language. The compiler I'm using is the Tiny C Compiler (tcc version 0.9.24) for the Windows platform. When executing the following code, it outputs the unexpected result 100, 99:

#include <stdio.h>
#include <math.h>

int main(void)
{
    printf("%d, ", (int) pow(10, 2));
    printf("%d", (int) pow(10, 2));
    return 0;
}

然而,在是预期输出的在线编译: 100,100 。我不知道是什么原因造成这种行为。有什么想法吗?从我的编程错误,编译错误?

However, at this online compiler the output is as expected: 100, 100. I don't know what is causing this behavior. Any thoughts? Programming error from me, compiler bug?

推荐答案

您发现了TCC​​的错误。感谢那。该补丁刚刚将提交给存储库。这将包括在下一版本,但可能需要一段时间。当然,你可以拉来源,建立它自己。补丁是这里

You found a bug in tcc. Thanks for that. The patch has just been commited to the repository. It will be included in the next release, but that might take a while. You can of course pull the source and build it yourself. The patch is here

http://repo.or.cz/w/tinycc.git/commitdiff/73faaea227a53e365dd75f1dba7a5071c7b5e541

这篇关于POW()转换为整数时,意想不到的结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆