mirror of
https://github.com/Redume/Shirino.git
synced 2025-02-04 09:58:57 +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
|
@ -1,14 +1,12 @@
|
|||
from utils.format_number import format_number
|
||||
|
||||
import yaml
|
||||
|
||||
import aiohttp
|
||||
import json
|
||||
import re
|
||||
|
||||
from datetime import datetime
|
||||
from decimal import Decimal
|
||||
from http import HTTPStatus
|
||||
from decimal import Decimal, ROUND_DOWN
|
||||
|
||||
import aiohttp
|
||||
import yaml
|
||||
|
||||
from utils.format_number import format_number
|
||||
|
||||
config = yaml.safe_load(open('config.yaml'))
|
||||
|
@ -24,8 +22,7 @@ class Converter:
|
|||
if not await self.kekkai():
|
||||
await self.ddg()
|
||||
|
||||
number = Decimal(str(self.conv_amount))
|
||||
self.conv_amount = format_number(number.quantize(Decimal('1.0000'), rounding=ROUND_DOWN))
|
||||
self.conv_amount = format_number(Decimal(self.conv_amount))
|
||||
|
||||
|
||||
async def kekkai(self) -> bool:
|
||||
|
|
|
@ -6,7 +6,7 @@ def format_number(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
Reference in a new issue