math.modf()

Type Function
Library math.*
Return value Numbers
Revision 2017.3060
Keywords modf

Overview

Returns two numbers, the integral part of x and the fractional part of x.

For the modulus (remainder), use the modulo operator % instead.

Syntax

math.modf( x )
x (required)

Number. A number.

Examples

print( math.modf(5) )     ---->  5       0
print( math.modf(5.3) )   ---->  5       0.3
print( math.modf(-5.3) )  ----> -5      -0.3
local myNumber = 4.75
local integralPart, fractionalPart = math.modf( myNumber )
print( "Integral Part:", integralPart )
print( "Fractional Part:", fractionalPart )