aproximate a number

rafi rafi at free.fr
Sun Aug 28 17:18:50 EDT 2005


billiejoex wrote:
> Hi all. I'd need to aproximate a given float number into the next (int) 
> bigger one. Because of my bad english I try to explain it with some example:
> 
> 5.7 --> 6
> 52.987 --> 53
> 3.34 --> 4
> 2.1 --> 3
> 
> Regards 
> 
> 

math.ceil returns what you need but as a float, then create an int

 >>> import math
 >>> math.ceil (12.3)
13.0
 >>> int (math.ceil (12.3))
13

hth

-- 
rafi

	"Imagination is more important than knowledge."
	                            (Albert Einstein)



More information about the Python-list mailing list