问个笨问题:double WPropertion = picctrlWidth/ imageWidth ;
wpropertion的值是多少,其中picctrlWidth=466,imageWidth=567 

解决方案 »

  1.   

    double的精度是16位,应该是0.0000 0000 0000 000
    picctrlWidth和imageWidth为int型,picctrlWidth/ imageWidth  = 0;然后强制转换为double
    应该是上面那个数
      

  2.   

    如果是这样
    int picctrlWidth=466,imageWidth=567;
    double WPropertion = picctrlWidth/ imageWidth ;
    结果为0
    如是这样
    int picctrlWidth=466,imageWidth=567;
    double WPropertion = (double)picctrlWidth/ imageWidth ;
    结果是我1楼的
      

  3.   


    #include "stdafx.h"int main(int argc, char* argv[])
    {
    int picctrlWidth=466;
    int imageWidth=567; double WPropertion = picctrlWidth/ imageWidth ; 
    printf("%d\n",WPropertion);
    return 0;
    }
    结果为:0
      

  4.   

    double WPropertion = picctrlWidth/ imageWidth ;
    先计算后赋值, 计算的结果按整数,是0, 0 赋值给double,还是0