Ref Math Modf
## Python math.modf() Function
The `math.modf()` function in Python is used to split a floating-point number into its fractional and integer parts. It returns a tuple containing two elements:
1. The fractional part of the number.
2. The integer part of the number.
### Syntax
```python
math.modf(x)
### Parameters
* `x` - A floating-point number.
### Return Value
A tuple `(fractional_part, integer_part)` where both values are floats.
### Example
```python
import math
print(math.modf(10.56))
print(math.modf(10.00))
print(math.modf(-10.10))
### Output
(0.5600000000000005, 10.0)
(0.0, 10.0)
(-0.10000000000000009, -10.0)
### Explanation
In the first example, `math.modf(10.56)` returns `(0.56, 10.0)`, meaning that the fractional part is `0.56` and the integer part is `10.0`.
In the second example, `math.modf(10.00)` returns `(0.0, 10.0)`, indicating that there's no fractional part.
In the third example, `math.modf(-10.10)` returns `(-0.10000000000000009, -10.0)`, showing the negative fractional part and the integer part.
### Related Topics
YouTip