我写了这样一个变量声明:
static float r=0.01;
但是编译器说
possible loss of precision ;
found double,requried float;
如果改为static float r=(float)0.01;就没问题了;
为什么会把0.01认为是double而不是float的呢?
static float r=0.01;
但是编译器说
possible loss of precision ;
found double,requried float;
如果改为static float r=(float)0.01;就没问题了;
为什么会把0.01认为是double而不是float的呢?
你可以这样
float x = 0.01f;也就是加个 f 后缀就行了。