blob: 3111f39c269a3e0ecfa649b5133577a963d14ded (
plain) (
blame)
1
2
3
4
5
6
7
8
9
|
#!/usr/bin/python
"""Miscellanious utility functions that don't fit anywhere."""
def format_float(num, numplaces):
if abs(round(num, numplaces) - round(num, 0)) == 0.0:
return '%.0f' % float(num)
else:
return ('%.' + numplaces + 'f') % round(float(num), numplaces)
|