求一种比较简便或者直接的方法?
谢谢了!

解决方案 »

  1.   

    COleCurrency cur;
    float fValue;
    ((CURRENCY)cur).int64 = fValue * 10000.0F;
      

  2.   

    如何将一个double数值转换成COleCurrency,在将COleCurrency转换回double,并且保留响应的有效位数
    ---------------------------------------------------------------  
     
    CY  cy;  
    double  db;  
    COleCurrency  olecy;  
     
    //  double  转换成COleCurrency;  
    VarCyFromR8  (db,  &cy);  
    olecy  =  cy;  
     
    //  COleCurrenCy转换成double  
    VarR8FromCy  (olecy,  &db);  
     
    上面用到的两个函数在oleauto.h中  
     
    ---------------------------------------------------------------  
     
    COleCurrency  curA;  //  value:  0.0000  
    curA.SetCurrency(4,  500); //  value:  4.0500  
     
    //  value  returned:  4.05  
    CString  sVal  =  curA.Format(0,  MAKELCID(MAKELANGID(LANG_CHINESE,  
     SUBLANG_CHINESE_SINGAPORE),  SORT_DEFAULT));  
    //  value  returned:  4,05  
    curA.Format(0,  MAKELCID(MAKELANGID(LANG_GERMAN,  
     SUBLANG_GERMAN_AUSTRIAN),  SORT_DEFAULT));  
    然后在将返回的"4.05"转换成double。  
    double  db  =  atof(sVal);  
      

  3.   

    COleCurrency cur;
    float fValue;
    ((CURRENCY)cur).int64 = fValue * 10000.0F;有错误呀!