[Python-Dev] trunc() (original) (raw)
Facundo Batista facundobatista at gmail.com
Fri Jan 25 13:28:36 CET 2008
- Previous message: [Python-Dev] [python] Re: trunc()
- Next message: [Python-Dev] trunc()
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
2008/1/24, Guido van Rossum <guido at 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 at 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
BTW, int is not giving me a deprecation warning:
int(.1) 0
Thanks!
-- . Facundo
Blog: http://www.taniquetil.com.ar/plog/ PyAr: http://www.python.org/ar/
- Previous message: [Python-Dev] [python] Re: trunc()
- Next message: [Python-Dev] trunc()
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]