Divide returns 0 instead of float

前端 未结 4 639
-上瘾入骨i
-上瘾入骨i 2021-01-17 05:17

I was very surprised when I found out my code wasn\'t working so I created a console application to see where the problem lies and I\'ve got even more surprised when I saw t

4条回答
  •  失恋的感觉
    2021-01-17 06:07

    You are using integer arithmetic and then converting the result to a float. Use floating-point arithmetic instead:

    float test = 140f / 1058f;
    

提交回复
热议问题