warning C4244: 'initializing' : conversion from 'double' to 'float', possible loss of datawarning C4244: 'argument' : conversion from 'double' to 'int', possible loss of datawarning C4244: '+=' : conversion from 'double' to 'long', possible loss of data另:我的数值范围是正负100之间,比如90.89966969,-12.09965547

解决方案 »

  1.   

    “conversion”从“double”转换到“float”,可能丢失数据
    “conversion”从“double”转换到“int”,可能丢失数据
    “conversion”从“double”转换到“long”,可能丢失数据
    Integer 类型转换为更小的 Integer 类型。如果 type1 是 int,且 type2 比 int 小,则这是警告等级 4。否则,为等级 3(将 __int64 类型的值赋给 unsigned int 类型的变量)。可能发生了数据丢失。如果获取 C4244,则应将程序更改为使用兼容类型,或向代码中添加一些逻辑,以确保可能值的范围始终与所使用的类型兼容。此转换可能会因隐式转换而出现问题。下面的示例生成 C4244:  复制代码 
    // C4244_level4.cpp// compile with: /W4
    int aa;
    unsigned short bb;
    int main() {
       int b = 0, c = 0;
       short a = b + c;   // C4244   bb += c;   // C4244
       bb = bb + c;   // C4244
       bb += (unsigned short)aa;   // C4244
       bb = bb + (unsigned short)aa;   // OK
    }
     有关更多信息,请参见常用算术转换。  复制代码 
    // C4244_level3.cpp// compile with: /W3
    int main() {
       __int64 i = 8;
       unsigned int ii = i;   // C4244
    }
     在使用 /Wp64 编译时也会发生 C4244 错误。请注意,对于使用应用程序向导创建的项目,/Wp64 默认是启用的。下面的示例生成 C4244:  复制代码 
    // C4244_level3_b.cpp// compile with: /W3 /Wp64
    int main() {
       char* p1 = 0;
       char* p2 = 0;
       int x = p2 - p1;   // C4244
    }
     
      

  2.   

    warning C4244: 'initializing' : conversion from 'double' to 'float', possible loss of data 
    数据太大不会有问题warning C4244: 'argument' : conversion from 'double' to 'int', possible loss of data 
    小数部分没了,数据也不能太大warning C4244: '+=' : conversion from 'double' to 'long', possible loss of data 
    小数部分没了,数据也不能太大