math.modf

Return the integer and fractional parts of number.

ExamplePrint the integral and fractional parts of user input
Read a single number from the user, then print its integral and fractional parts.
Code
<nowiki>
print(math.modf(tonumber(read())))
    </nowiki>
Output Depends. If the user wrote 5.2, the numbers printed will be 5 0.2

math.modf
Function
Syntax
math.modf(
  • number : number
)

Returns number integral, number fractional
API math
Source Lua (source)
This article is issued from Computercraft. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.