math.fmod(x, y)x 除以 y 的餘數。math.fmod(x, y)
x (float): 被除數。y (float): 除數。x 除以 y 的餘數。import math
print(math.fmod(20, 3)) # 輸出: 2.0
math.frexp(x)x 分解為尾數和指數。math.frexp(x)
x (float): 要分解的數值。import math
print(math.frexp(8)) # 輸出: (0.5, 4)
math.fsum(iterable)math.fsum(iterable)
iterable: 一個可迭代對象,包含要計算總和的數值。import math
print(math.fsum([0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1])) # 輸出: 1.0
math.gcd(*integers)math.gcd(*integers)
integers: 多個整數。import math
print(math.gcd(48, 64, 32)) # 輸出: 16
math.isclose(a, b, *, rel_tol=1e-09, abs_tol=0.0)math.isclose(a, b, *, rel_tol=1e-09, abs_tol=0.0)
a (float): 第一個值。b (float): 第二個值。rel_tol (float, 可選): 相對誤差,默認為 1e-09。abs_tol (float, 可選): 絕對誤差,默認為 0.0。True,否則返回 False。import math
print(math.isclose(1.0000001, 1.0000002)) # 輸出: True