Why does this integer division yield 0?

前端 未结 4 1130
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-19 14:53

Could someone tell me why the following code is outputting 0 at the marked line?

It seems as if everything is correct but then when I try to get the re

4条回答
  •  不知归路
    2021-01-19 15:31

    You are printing integers and therefore it will round down the value.

    timeLapseInterval / totalFrames will be (1 / frameRate) which will be < 1 unless frameRate is 1 (or 0 in which case you have an error dividing by 0)

提交回复
热议问题