ConceptPythonBeginner
Floating-point numbers: why 0.1 + 0.2 is not 0.3, and a derivative's best step
- eps = np.finfo(float).eps
- print(f"powers of two in normal floats: {np.finfo(float).minexp} to {np.finfo(float).maxexp - 1}")
- print(f"decimal digits in 53 bits: {53 * math.log10(2):.2f}; safe round trip: {np.finfo(float).precision}")
- print(f"machine epsilon {float(np.finfo(float).eps)!r}")
- eps32 = np.finfo(np.float32).eps