Changeset 1255
- Timestamp:
- Mar 19, 2014 2:55:17 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIpy3.py
r1236 r1255 145 145 else: # larger numbers, remove decimal places 146 146 decimals = sigfigs - 1 - int(np.log10(abs(val))) 147 fmt = "{" + (":{:d}.{:d}f".format(maxdigits,decimals))+"}" 148 if decimals == 0: fmt += "." # force a decimal place 147 if decimals <= 0: 148 fmt = "{" + (":{:d}.0f".format(maxdigits))+"}." 149 else: 150 fmt = "{" + (":{:d}.{:d}f".format(maxdigits,decimals))+"}" 149 151 try: 150 152 return fmt.format(float(val)).strip() … … 160 162 for i in (1,10,100,1000,10000,100000,1000000,10000000,100000000): 161 163 print FormatSigFigs(1.23456789e9/i),1.23456789e9/i 164 165 print FormatSigFigs(200,10,3)
Note: See TracChangeset
for help on using the changeset viewer.