python Programming Glossary: sigfig
Nicely representing a floating-point number in python http://stackoverflow.com/questions/2663612/nicely-representing-a-floating-point-number-in-python maximum precision is 15 significant digits. def f number sigfig return .15f round number int 1 floor log10 number sigfig 1 .rstrip.. sigfig return .15f round number int 1 floor log10 number sigfig 1 .rstrip 0 .rstrip . print f 0.1 1 0.1 print f 0.0000000000368568.. numerator denominator return result def f number sigfig # http stackoverflow.com questions 2663612 nicely representing..
|