Skip to content

Tag Archives: engineering notation

Python script for engineering format

21-Oct-11

[cce_python] # -*- coding: cp1252 -*- from math import tan, pi, sqrt, log, floor def eng(x, sigfigs=3): m = floor(log(x)/log(10)/3)*3 LUT = { -18: “a”, -15: “f”, -12: “p”, -9: “n”, -6: “ยต”, -3: “m”, 0: “”, 3: “k”, 6: “M”, 9: “G” } return (“{0:.{1}g}{2}”).format(x*10.0**(-m), sigfigs, LUT[m]) [/cce_python] I’m not sure what grief the […]