Derek Basch wrote: > Given a value (x) that is within the range (1e-1, 1e7) how do I round > (x) up to the closest exact logarithmic decade? For instance: > > 10**3 = 1000 > x = 4978 > 10**4 = 10000 > x = 10000
how about >>> import math >>> def roundup(x): ... return 10**math.ceil(math.log10(x)) ... >>> roundup(4978) 10000.0 ? </F> -- http://mail.python.org/mailman/listinfo/python-list