math.ceil

math.ceil
Function
Syntax
math.ceil(
  • num : number
)

Returns number
API math
Source Lua (source)

Return num rounded to the next whole integer.

ExampleRound the value of user input
Read a line from the user, then print the ceiling of the number they entered.
Code
<nowiki>
print(math.ceil(tonumber(read())))
    </nowiki>
Output Depends on what the user wrote. For instance, if they were to enter 0.2, the number printed would be 1.
This article is issued from Computercraft. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.