Simple division operation returning zero?

前端 未结 5 1444
醉酒成梦
醉酒成梦 2021-01-29 13:48

What am I missing?

float stepSize = 0.0f;
int activeCircleRadius = 10;
int numSteps = 24;

AiLog.v(\"init activeCircleRadius \" + activeCircleRadius + \" numStep         


        
5条回答
  •  时光取名叫无心
    2021-01-29 14:50

     With all arithmetic operators in Java, the result has the type of the largest operator. For instance: 
    - float operator long => float 
    - int operator int => int 
    - int operator long => long 
    
    
    float stepSize = 0f;
            float activeCircleRadius = (float) 10.0;
            int numSteps = 24;
            stepSize = activeCircleRadius / numSteps;
    

提交回复
热议问题