比如说我取得一个double型的数34,现在我想转换成这个样子CString型"0.34",还有就是另一个double型的三位数345,现在我想转换成这个样子CString型"3.45",当然这里面有个除以100的动作,不知道如何处理,请高手写出代码.谢谢

解决方案 »

  1.   

    double x = 34;
    CString str;
    str.Foramt("%lf",x/100.0);
      

  2.   

    楼上的Format写错了。。呵呵。。
      

  3.   

    同意斑竹
    如果反过来可以:
    CString str="34.12";
    float x=float(atof(str));
      

  4.   

    double x = 34;
    x = x /100;
    CString str;
    str.Foramt("%0.2f",x);
      

  5.   

    double d0=34,d1=345;
    CString str;
    str.Format("%.2f",d0/100);
    str.Format("%.2f",d1/100);
      

  6.   

    上面的都有错误 double有精度的
    double d0=34,d1=345;
    CString str
    str.Format("%.2f",(d0+0.5)/100));
    str.Format("%.2f",(d1+0.5)/100));