mirror of
https://github.com/bblaz/num2words.git
synced 2025-12-06 06:42:25 +00:00
Fix lang_IT handling of floats (#143)
`n % 1 != 0` is not a valid test for float: In []: 1.1 % 1 == 0 Out[]: False but: In []: 1.0 % 1 == 0 Out[]: True hence it's really necessary to explicitly test for type in this case.
This commit is contained in:
committed by
Ernesto Rodriguez Ortiz
parent
8ffdc5e49d
commit
efce631944
@@ -169,7 +169,7 @@ class Num2Word_IT:
|
||||
def to_cardinal(self, number):
|
||||
if number < 0:
|
||||
string = Num2Word_IT.MINUS_PREFIX_WORD + self.to_cardinal(-number)
|
||||
elif number % 1 != 0:
|
||||
elif isinstance(number, float):
|
||||
string = self.float_to_words(number)
|
||||
elif number < 20:
|
||||
string = CARDINAL_WORDS[number]
|
||||
|
||||
Reference in New Issue
Block a user