mirror of
https://github.com/bblaz/num2words.git
synced 2025-12-06 06:42:25 +00:00
Fixed bug with minus currency rounding
This commit is contained in:
@@ -63,12 +63,14 @@ aštuoniasdešimt keturi milijonai du šimtai dvidešimt tūkstančių du
|
|||||||
>>> print(fill(n2w(1000000000000000000000000000000)))
|
>>> print(fill(n2w(1000000000000000000000000000000)))
|
||||||
naintilijonas
|
naintilijonas
|
||||||
|
|
||||||
>>> print(to_currency(1, 'LTL'))
|
>>> print(to_currency(1.0, 'LTL'))
|
||||||
vienas litas, nulis centų
|
vienas litas, nulis centų
|
||||||
|
|
||||||
>>> print(to_currency(1234.56, 'LTL'))
|
>>> print(to_currency(1234.56, 'LTL'))
|
||||||
tūkstantis du šimtai trisdešimt keturi litai, penkiasdešimt šeši centai
|
tūkstantis du šimtai trisdešimt keturi litai, penkiasdešimt šeši centai
|
||||||
|
|
||||||
|
>>> print(to_currency(-1251985, cents = False))
|
||||||
|
minus dvylika tūkstančių penki šimtai devyniolika litų, 85 centai
|
||||||
"""
|
"""
|
||||||
|
|
||||||
ZERO = (u'nulis',)
|
ZERO = (u'nulis',)
|
||||||
@@ -193,12 +195,14 @@ def n2w(n):
|
|||||||
|
|
||||||
def to_currency(n, currency='LTL', cents = True):
|
def to_currency(n, currency='LTL', cents = True):
|
||||||
if type(n) == int:
|
if type(n) == int:
|
||||||
left = abs(n / 100)
|
|
||||||
right = abs(n % 100)
|
|
||||||
if n < 0:
|
if n < 0:
|
||||||
minus = True
|
minus = True
|
||||||
else:
|
else:
|
||||||
minus = False
|
minus = False
|
||||||
|
|
||||||
|
n = abs(n)
|
||||||
|
left = n / 100
|
||||||
|
right = n % 100
|
||||||
else:
|
else:
|
||||||
n = str(n).replace(',', '.')
|
n = str(n).replace(',', '.')
|
||||||
if '.' in n:
|
if '.' in n:
|
||||||
|
|||||||
Reference in New Issue
Block a user