On Jan 25, 2008 4:28 AM, Facundo Batista <facundobatista@gmail.com> wrote:
2008/1/24, Guido van Rossum <guido@python.org>:
So you won't be able to construct an int from a float? That sucks (and is unintuitive).
Yes, you can, but you have to specify how you want it done by using trunc() or round() or ceil() or floor(). (In 3.0, round(x) will return an int, not a float.)
2008/1/24, Jeffrey Yasskin <jyasskin@gmail.com>:
That needs to be updated and implemented. I think the decision was that removing float.__int__() would break too much, so it needs a deprecation warning in 3.0.
What I understand here is as int() is "ambiguous", in the future if you want to specify how you want to convert a float to int.
But ceil and floor returns a float. And round and trunc will return an int. So, how I could convert a float to its upper int? Like this?:
trunc(math.ceil(.3)) 1
Like this, in 3.0:
math.ceil(2.2) 3
There was a previous thread in which we decided not to change that behavior in 2.6.
BTW, int is not giving me a deprecation warning:
int(.1) 0
Correct; that's not implemented yet. -- Namasté, Jeffrey Yasskin http://jeffrey.yasskin.info/