This seems to work for me: math.ceil(val*4)/4
math.ceil(val*4)/4
Posted by Greg Pinero (Primary Searcher) on Aug 22nd, 2010 and is filed under Python.
Both comments and pings are currently closed.
Add this post to Del.icio.us - Digg
Without using the math module:
x if 4*x == int(4*x) else int(4*x+1)/4.0
Rounding down is easier:
int(4*x)/4.0
Without using the math module, it’s even simpler:
round(num*4)/4
Sorry Missed the round “up” part.
Without using the math module:
x if 4*x == int(4*x) else int(4*x+1)/4.0
Rounding down is easier:
int(4*x)/4.0
Without using the math module, it’s even simpler:
round(num*4)/4
Sorry
Missed the round “up” part.