Type Function Library math.* Return value Numbers Revision Current Public Release (2018.3326) Keywords modf
Returns two numbers, the integral part of x
and the fractional part of x
.
For the modulus (remainder), use the modulo operator %
instead.
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 ) |