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_fujian import DataFujian
from commons.models.data_network import DataNetwork from commons.models.data_network import DataNetwork
@@ -37,7 +37,8 @@ class Helper:
class RoundMethod: class RoundMethod:
@staticmethod @staticmethod
def normal(n, round_bit): 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) return result if round_bit != 0 else int(result)
@staticmethod @staticmethod

View File

@@ -39,7 +39,7 @@ if __name__ == '__main__':
from core.factory import ClientApp from core.factory import ClientApp
with ClientApp().app_context(): with ClientApp().app_context():
calculate(2025, 3) calculate(2025, 5)
# for i in range(2, 12): # for i in range(2, 12):
# calculate(2022, i+1) # calculate(2022, i+1)