Skip to content

Commit

Permalink
IT: support Decimal class
Browse files Browse the repository at this point in the history
  • Loading branch information
bryananderson committed Dec 15, 2024
1 parent 0df2a0e commit c7755ee
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion num2words/lang_IT.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def big_number_to_cardinal(self, number):
def to_cardinal(self, number):
if number < 0:
string = Num2Word_IT.MINUS_PREFIX_WORD + self.to_cardinal(-number)
elif isinstance(number, float):
elif int(number) != number:
string = self.float_to_words(number)
elif number < 20:
string = CARDINAL_WORDS[int(number)]
Expand Down
3 changes: 3 additions & 0 deletions tests/test_it.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ def test_negative(self):
self.assertEqual("meno " + pos_ord, neg_ord)

def test_float_to_cardinal(self):
self.assertEqual(
num2words("3.1415", lang="it"), "tre virgola uno quattro uno cinque"
)
self.assertEqual(
num2words(3.1415, lang="it"), "tre virgola uno quattro uno cinque"
)
Expand Down

0 comments on commit c7755ee

Please sign in to comment.