5 from decimal
import Decimal
117 pi = Decimal((0, pi_digits, 1 - len(pi_digits)))
123 c_m_s = Decimal((0, (2, 9, 9, 7, 9, 2, 4, 5, 8), 0))
125 e_C = Decimal((0, (1, 6, 0, 2, 1, 7, 6, 6, 3, 4), -28))
127 h_Js = Decimal((0, (6, 6, 2, 6, 0, 7, 0, 1, 5), -42))
129 h_MeVs = h_eVs / Decimal((0, (1,), 6))
130 h_GeVs = h_eVs / Decimal((0, (1,), 9))
132 hbar_Js = h_Js / (2 * pi)
133 hbar_eVs = h_eVs / (2 * pi)
134 hbar_MeVs = h_MeVs / (2 * pi)
135 hbar_GeVs = h_GeVs / (2 * pi)
138 degree_radian = pi / Decimal((0, (1, 8, 0), 0))
140 J_GeV = J_eV / Decimal((0, (1,), 9))
144 (
"speed of light in vacuum", c_m_s,
"m/s"),
145 (
"electron charge", e_C,
"C"),
146 (
"Planck constant", h_Js,
"J*s"),
147 (
"Planck constant", h_eVs,
"eV*s"),
148 (
"Planck constant", h_MeVs,
"MeV*s"),
149 (
"Planck constant", h_GeVs,
"GeV*s"),
150 (
"reduced Planck constant", hbar_Js,
"J*s"),
151 (
"reduced Planck constant", hbar_eVs,
"eV*s"),
152 (
"reduced Planck constant", hbar_MeVs,
"MeV*s"),
153 (
"reduced Planck constant", hbar_GeVs,
"GeV*s"),
154 (
"degree", degree_radian,
"radian"),
155 (
"Joule", J_eV,
"eV"),
156 (
"Joule", J_GeV,
"GeV"),
158 float_constants = [(n, float(v), u)
for n, v, u
in full_constants]
163 max_len_name = max((len(n)
for n, *_
in constants))
164 line_format = f
"{{:>{max_len_name}}}: {{}} {{}}"
165 for name, value, unit
in constants:
166 print(line_format.format(name, value, unit))
170 print(
"=== high precision values:")
172 print(
"=== double precision values:")