Lua: converting from float to int

后端 未结 4 1827
耶瑟儿~
耶瑟儿~ 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条回答
  •  清歌不尽
    2021-02-02 07:27

    Lua 5.3 introduced a new operator, called floor division and denoted by //

    Example below:

    Lua 5.3.1 Copyright (C) 1994-2015 Lua.org, PUC-Rio

    >12//5

    2

    More info can be found in the lua manual

提交回复
热议问题