diff python/utils.py @ 32:48e56179c39e

added ceil function
author Nicolas Saunier <nico@confins.net>
date Sat, 10 Apr 2010 18:58:43 -0400
parents c000f37c316d
children 8cafee54466f
line wrap: on
line diff
--- a/python/utils.py	Sat Feb 13 19:46:33 2010 -0500
+++ b/python/utils.py	Sat Apr 10 18:58:43 2010 -0400
@@ -31,6 +31,13 @@
 # maths section
 #########################
 
+def ceilDecimals(v, nDecimals):
+    '''Rounds the number at the nth decimal
+    eg 1.23 at 0 decimal is 2, at 1 decimal is 1.3'''
+    from math import ceil,pow
+    tens = pow(10,nDecimals)
+    return ceil(v*tens)/tens
+
 def segmentIntersection(p1, p2, p3, p4):
     '''Returns the intersecting point of the segments [p1, p2] and [p3, p4], None otherwise'''
     from numpy import matrix