Paul Moore wrote: > On 24/01/2008, Jeffrey Yasskin <[EMAIL PROTECTED]> wrote: >> int has to be a builtin because it's a fundamental type. trunc() >> followed round() into the builtins. I have no opinion on whether ceil >> and floor should move there; it probably depends on how often they're >> used. > > Suggestion: > > - int() has to stay in builtins for obvious reasons. > - put *all* of trunc, ceil, floor, round into math. > - make int(float) an error
Slightly different suggestion: - define int(float) as int(trunc(float)) In my humble opinion lots of people expect int(-2.5) == -2 and int(2.5) == 2. Or in other words: int(float) chops of the digits after the dot. As far as I can see float.__int__ already behaves like int(trunc(float)) >>> for n in (2.4, 2.6, -2.4, -2.6): ... print(n, (math.floor(n), math.ceil(n), round(n), trunc(n), int(n))) ... Python 3:0 2.4 ( 2, 3, 2, 2, 2) 2.6 ( 2, 3, 3, 2, 2) -2.4 (-3, -2, -2, -2, -2) -2.6 (-3, -2, -3, -2, -2) Python 2.6: 2.4 ( 2.0, 3.0, 2.0, 2, 2) 2.6 ( 2.0, 3.0, 3.0, 2, 2) -2.4 (-3.0, -2.0, -2.0, -2, -2) -2.6 (-3.0, -2.0, -3.0, -2, -2) Christian _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com