hi,
i want my 2.25x10^12 to be rounded to 2x10^12 and 2.75x10^12 to 3x10^12.
How can i do that?
thanx
i want my 2.25x10^12 to be rounded to 2x10^12 and 2.75x10^12 to 3x10^12.
How can i do that?
thanx
>>> def round_length_near(length, increment=.0625): ... if not increment: ... return length ... return round(length/float(increment)) * increment ... >>> round_length_near(22500000000, 10000000000) 20000000000.0 >>> round_length_near(27500000000, 10000000000) 30000000000.0
>>> "%e" % 22500000000
'2.250000e+010'
>>> float('2.250000e+010')
22500000000.0
>>>
Comment