aproximate a number
Michael Sparks
ms at cerenity.org
Sun Aug 28 17:33:05 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
What about 2.0? By your spec that should be rounded to 3 - is that what you
intend?
If you do, you can simply do this:
def approx(x):
return int(x+1.0)
Regards,
Michael.
More information about the Python-list
mailing list