fix: Error with Decimal if the number was too large

This commit is contained in:
Данил 2025-01-09 23:03:38 +03:00
parent 0eafaba090
commit c9eb773f10
2 changed files with 9 additions and 12 deletions

View file

@ -2,11 +2,11 @@ from decimal import Decimal
def format_number(number):
number = Decimal(str(number))
formatted_integer_part = '{:,.0f}'.format(number).replace(',', ' ')
if '.' in str(number):
fractional_part = str(number).split('.')[1]
fractional_part = str(number).split('.')[1][:3]
return formatted_integer_part + '.' + fractional_part
else:
return formatted_integer_part