Lua: converting from float to int

后端 未结 4 1828
耶瑟儿~
耶瑟儿~ 2021-02-02 06:51

Even though Lua does not differentiate between floating point numbers and integers, there are some cases when you want to use integers. What is the best way to covert a number t

4条回答
  •  梦毁少年i
    2021-02-02 07:22

    You could use math.floor(x)

    From the Lua Reference Manual:

    Returns the largest integer smaller than or equal to x.

提交回复
热议问题