fix: 替换四六舍入为四五舍入

This commit is contained in:
han0
2025-06-05 18:57:35 +08:00
parent 1402b1a1e3
commit 80272d2bf3
2 changed files with 4 additions and 3 deletions

View File

@@ -1,4 +1,4 @@
from decimal import Decimal
from decimal import Decimal, ROUND_HALF_UP
from commons.models.data_fujian import DataFujian
from commons.models.data_network import DataNetwork
@@ -37,7 +37,8 @@ class Helper:
class RoundMethod:
@staticmethod
def normal(n, round_bit):
result = round(n, round_bit)
q_ext = Decimal('0.' + '0' * round_bit)
result = Decimal(n).quantize(q_ext, rounding=ROUND_HALF_UP)
return result if round_bit != 0 else int(result)
@staticmethod