This commit is contained in:
沈瑗杰 2020-12-22 18:42:12 +08:00
parent 6ed95a8096
commit a655c9a5ec
3 changed files with 24 additions and 35 deletions

View File

@ -7,49 +7,41 @@ import libs
import math import math
def P_C_M(A, B): # stand for Scientific notation multiple def S_C_float_check(SC): # stand for Scientific notation's float check\
""" """
formats: formats:
A & B list format:docs.basic_config.json:basic_number SC list format:docs.basic_config.json:basic_number"""
while SC[0] >= 10:
SC[0] /= 10
SC[1] += 1
while SC[0] < 1:
SC[0] *= 10
SC[1] -= 1
def S_N_M(A, B): # stand for Scientific notation multiple
""" """
C = [0.0, 1, [], []] formats:
Float = float(A[0] * B[0]) A & B list format:docs.basic_config.json:basic_number"""
Int = int(A[1] + B[1]) C = [float(A[0] * B[0]), int(A[1] + B[1])]
if Float >= 10: S_C_float_check(C)
Float /= 10
Int += 1
elif Float <= 1:
Float *= 10
Int -= 1
else:
pass
Unit1, Unit2 = A[2] + B[2], A[3] + B[3] Unit1, Unit2 = A[2] + B[2], A[3] + B[3]
if Unit1 == None: if Unit1 == None:
Unit1 = [] Unit1 = []
libs.tools.D_C(Unit1, Unit2) libs.tools.D_C(Unit1, Unit2)
C = [Float, Int, Unit1, Unit2] C += [Unit1, Unit2]
return C return C
def P_C_D(A, B): # stand for Physics Calculation divide def S_N_D(A, B): # stand for Scientific notation divide
""" """
formats: formats:
A & B list format:docs.basic_config.json:basic_number A & B list format:docs.basic_config.json:basic_number"""
""" C = [float(A[0] / B[0]), int(A[1] - B[1])]
C = [0.0, 1, [], []] S_C_float_check(C)
Float = float(A[0] / B[0])
Int = int(A[1] - B[1])
if Float >= 10:
Float /= 10
Int += 1
elif Float <= 0.01:
Float *= 10
Int -= 1
else:
pass
Unit1, Unit2 = A[2] + B[3], A[3] + B[2] Unit1, Unit2 = A[2] + B[3], A[3] + B[2]
if Unit1 == None: if Unit1 == None:
Unit1 = [] Unit1 = []
libs.tools.D_C(Unit1, Unit2) libs.tools.D_C(Unit1, Unit2)
C = [Float, Int, Unit1, Unit2] C += [Unit1, Unit2]
return C return C

View File

@ -28,6 +28,3 @@ def D_C(listA, listB): # stand for Duplicate check
listA.sort() listA.sort()
listB.sort() listB.sort()
return return
def S_C_float_check(SC): # stand for Scientific notation's float check
pass

View File

@ -12,9 +12,9 @@ B = [0.245, -7, ["N", "kg"], ["m", "s"]]
print("A = " , A) print("A = " , A)
print("B = " , B) print("B = " , B)
C = libs.P_C.P_C_M(A, B) C = libs.P_C.S_N_M(A, B)
D = libs.P_C.P_C_D(A, B) D = libs.P_C.S_N_D(A, B)
E = libs.P_C.P_C_D(C, B) E = libs.P_C.S_N_D(C, B)
print("A × B = " , C) print("A × B = " , C)
print("A ÷ B = " , D) print("A ÷ B = " , D)