Skip to content

Commit 09b6a62

Browse files
authored
Update decimal_to_fraction.py
1 parent fff34ed commit 09b6a62

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

maths/decimal_to_fraction.py

+12
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,18 @@ def decimal_to_fraction(decimal: float | str) -> tuple[int, int]:
1616
>>> decimal_to_fraction("78td")
1717
Traceback (most recent call last):
1818
ValueError: Please enter a valid number
19+
>>> decimal_to_fraction(-2.5)
20+
(-5, 2)
21+
>>> decimal_to_fraction(0.125)
22+
(1, 8)
23+
>>> decimal_to_fraction(1000000.25)
24+
(4000001, 4000)
25+
>>> decimal_to_fraction(1.3333)
26+
(13333, 10000)
27+
>>> decimal_to_fraction("1.23e2")
28+
(123, 1)
29+
>>> decimal_to_fraction("0.500")
30+
(1, 2)
1931
"""
2032
try:
2133
decimal = float(decimal)

0 commit comments

Comments
 (0)