mirror of
https://github.com/Redume/Shirino.git
synced 2025-03-14 18:37:51 +03:00
fix: Error with Decimal if the number was too large
This commit is contained in:
parent
0eafaba090
commit
c9eb773f10
2 changed files with 9 additions and 12 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue