math.modf

Full name
math.modf
Library
math
Syntax

math.modf(number)

Description

The math.modf function returns the fractional part and the integer part of the number included as an argument.

Parameters
  • number: number to decompose into its fractional and integer part.
Result

The result returned by the math.modf function is a tuple.

Examples

We can obtain the fractional part and the integer part of the number π with the following code:

math.modf(math.pi)

(0.14159265358979312, 3.0)

We confirm that the function returns a tuple.

Submitted by admin on Sun, 01/24/2021 - 10:40