Does no-one thinks it means round(f) either? That's the main confusion
here (plus the fact that in C it's undefined -- or at some point was
undefined).

BTW the list of functions considered here should include round() in
addition to ceil(), floor(), and trunc(), even if 2-arg round()
doesn't quite fit.

--Guido

On Jan 25, 2008 11:22 AM, Raymond Hettinger <[EMAIL PROTECTED]> wrote:
> > If the decision comes to be that int(float) should be blessed
> > as a correct way to truncate a float, I'd agree with Raymond
> > that trunc() is just duplication and should be eliminated.
>
> Yay, we've make progress!
>
>
> > I'd,of course, rather have a spelling that says what it means. :)
>
> I wouldn't fret about this too much.  Intrepreting int(f) as
> meaning truncate has a *long* history in *many* programming
> languages.  It is a specious argument int(f) is ambiguous.
> No one thinks it means ceil(f).
>
> Go ask a dozen people if they are surprised that int(3.7) returns 3.
> No one will be surprised (even folks who just use Excel or VB). It
> is foolhardy to be a purist and rage against the existing art:
>
> SQL: "The INT() function returns its numeric argument with any fractional
> digits removed and truncates all digits to the right of the decimal
> point."
> www.basis.com/onlinedocs/documentation/b3odbc/bbjds_int_function.htm
>
> VB: "Both the Int and Fix functions remove the fractional part of
> Number and return the resulting integer value."
> http://msdn2.microsoft.com/en-us/library/xh29swte.aspx
>
> Excel: "The Int function returns the integer portion of a number."
> http://www.techonthenet.com/excel/formulas/int.php
>
> These docs suggest where the thinking has gone wrong.  Writing int(f)
> doesn't mean "arbritrary select one of round|ceil|floor|trunc as
> a way of getting to an integer"; instead, it means "return the
> integer portion (non-fractional component) of a number."  The
> latter definition seems common and is entirely unambiguous.
>
>
> Raymond
>
> _______________________________________________
> 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/guido%40python.org
>



-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)
_______________________________________________
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

Reply via email to