decimal!
This commit is contained in:
parent
e5ca9a5687
commit
e0aac26713
10
libs/P_C.py
10
libs/P_C.py
@ -8,16 +8,18 @@ file name stand for : Physics calculation
|
|||||||
import libs
|
import libs
|
||||||
import math
|
import math
|
||||||
|
|
||||||
|
from libs.tools import F_Mi, F_Mu, F_A, F_D
|
||||||
|
|
||||||
|
|
||||||
def S_C_float_check(SC): # stand for Scientific notation's float check
|
def S_C_float_check(SC): # stand for Scientific notation's float check
|
||||||
"""
|
"""
|
||||||
formats:
|
formats:
|
||||||
SC list format:docs.basic_config.json:basic_number"""
|
SC list format:docs.basic_config.json:basic_number"""
|
||||||
while SC[0] >= 10:
|
while SC[0] >= 10:
|
||||||
SC[0] /= 10
|
SC[0] = F_D(SC[0], 10)
|
||||||
SC[1] += 1
|
SC[1] += 1
|
||||||
while SC[0] < 1:
|
while SC[0] < 1:
|
||||||
SC[0] *= 10
|
SC[0] = F_Mu(SC[0], 10)
|
||||||
SC[1] -= 1
|
SC[1] -= 1
|
||||||
|
|
||||||
|
|
||||||
@ -25,7 +27,7 @@ def S_N_M(A, B): # stand for Scientific notation multiple
|
|||||||
"""
|
"""
|
||||||
formats:
|
formats:
|
||||||
A & B list format:docs.basic_config.json:basic_number"""
|
A & B list format:docs.basic_config.json:basic_number"""
|
||||||
C = [A[0] * B[0], int(A[1] + B[1])]
|
C = [F_Mu(A[0], B[0]), F_A(A[1], B[1])]
|
||||||
S_C_float_check(C)
|
S_C_float_check(C)
|
||||||
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:
|
||||||
@ -39,7 +41,7 @@ def S_N_D(A, B): # stand for Scientific notation divided
|
|||||||
"""
|
"""
|
||||||
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 = [F_D(A[0], B[0]), F_Mi(A[1], B[1])]
|
||||||
S_C_float_check(C)
|
S_C_float_check(C)
|
||||||
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:
|
||||||
|
@ -6,7 +6,7 @@ mail: 3695888@qq.com
|
|||||||
import libs.Game_threads
|
import libs.Game_threads
|
||||||
|
|
||||||
# import in this forder
|
# import in this forder
|
||||||
import libs.S_D
|
import libs.P_C
|
||||||
import libs.main
|
import libs.main
|
||||||
import libs.tools
|
import libs.tools
|
||||||
import libs.loads
|
import libs.loads
|
||||||
|
@ -35,16 +35,24 @@ def D_C(listA, listB): # stand for Duplicate check
|
|||||||
|
|
||||||
|
|
||||||
def F_Mu(A, B): # stand for float multiple
|
def F_Mu(A, B): # stand for float multiple
|
||||||
pass
|
a = decimal.Decimal(str(A))
|
||||||
|
b = decimal.Decimal(str(B))
|
||||||
|
return float(a * b)
|
||||||
|
|
||||||
|
|
||||||
def F_D(A, B): # stand for float divided
|
def F_D(A, B): # stand for float divided
|
||||||
pass
|
a = decimal.Decimal(str(A))
|
||||||
|
b = decimal.Decimal(str(B))
|
||||||
|
return float(a / b)
|
||||||
|
|
||||||
|
|
||||||
def F_P(A, B): # stand for float plus
|
def F_A(A, B): # stand for float plus
|
||||||
pass
|
a = decimal.Decimal(str(A))
|
||||||
|
b = decimal.Decimal(str(B))
|
||||||
|
return float(a + b)
|
||||||
|
|
||||||
|
|
||||||
def F_Mi(A, B): # stand for float minus
|
def F_Mi(A, B): # stand for float minus
|
||||||
pass
|
a = decimal.Decimal(str(A))
|
||||||
|
b = decimal.Decimal(str(B))
|
||||||
|
return float(a - b)
|
||||||
|
6
test.py
6
test.py
@ -12,9 +12,9 @@ B = [2.45, -7, ["N", "kg"], ["m", "s"]]
|
|||||||
print("A = " , A)
|
print("A = " , A)
|
||||||
print("B = " , B)
|
print("B = " , B)
|
||||||
|
|
||||||
C = libs.S_D.S_N_M(A, B)
|
C = libs.P_C.S_N_M(A, B)
|
||||||
D = libs.S_D.S_N_D(A, B)
|
D = libs.P_C.S_N_D(A, B)
|
||||||
E = libs.S_D.S_N_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)
|
||||||
|
Loading…
Reference in New Issue
Block a user