Skip to content

Commit cebf9b0

Browse files
author
Aastha Singh
committed
Add modf() in math.py
1 parent ac9b23f commit cebf9b0

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/runtime/math.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from ltypes import i8, i16, i32, f32, f64, ccall
1+
from ltypes import i8, i16, i32, i64, f32, f64, ccall, overload
22

33

44
pi: f64 = 3.141592653589793238462643383279502884197
@@ -8,6 +8,13 @@
88
# TODO: Change floor used inside functions implemented here to
99
# floordiv operator (//) once the multiple import issue is fixed
1010

11+
def modf(x: f64) -> tuple[f64, i32]:
12+
"""
13+
Return fractional and integral parts of `x` as a pair.
14+
"""
15+
16+
return (x - int(x), int(x))
17+
1118
def factorial(x: i32) -> i32:
1219
"""
1320
Computes the factorial of `x`.

0 commit comments

Comments
 (0)