Strange behaviour of the pow function

后端 未结 5 725
借酒劲吻你
借酒劲吻你 2020-11-22 12:23

While running the following lines of code:

int i,a;    

for(i=0;i<=4;i++)  
{    
    a=pow(10,i);    
    printf(\"%d\\t\",a);    
}   
5条回答
  •  感动是毒
    2020-11-22 13:04

    This is to do with floating point inaccuracy. Although you are passing in ints they are being implicitly converted to a floating point type since the pow function is only defined for floating point parameters.

提交回复
热议问题