Why is this simple piece of code not working?

前端 未结 5 831
悲哀的现实
悲哀的现实 2021-01-26 03:36

I am trying to get a floating variable accurate to just 3 decimal points for a comparison calculation. I am trying the method below, but it doesn\'t work. I can\'t see why not,

5条回答
  •  星月不相逢
    2021-01-26 03:51

    bb is int. So bb/1000 is doing a int division, which results again in an int = 1000 (no decimals). That int value is cast to a double.

提交回复
热议问题