math.modf

From ComputerCraft
Jump to: navigation, search

math.modf
Function
Syntax
math.modf()
Returns number integral, number fractional
API math
Source Lua (source)

Return the integer and fractional parts of number.

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