A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/2007-January/070798.html below:

[Python-Dev] Floor division

[Python-Dev] Floor divisionNick Maclaren nmm1 at cus.cam.ac.uk
Fri Jan 26 10:19:23 CET 2007
"Guido van Rossum" <guido at python.org> wrote:
>
> "(int)float_or_double" truncates in C (even in K&R C) /provided that/
> the true result is representable as an int.  Else behavior is
> undefined (may return -1, may cause a HW fault, ...).

Actually, I have used Cs that didn't, but haven't seen any in over
10 years.  C90 is unclear about its intent, but C99 is specific that
truncation is towards zero.  This is safe, at least for now.

> So Python uses C's modf() for float->int now, which is always defined
> for finite floats, and also truncates.

Yes.  And that is clearly documented and not currently likely to
change, as far as I know.


Regards,
Nick Maclaren,
University of Cambridge Computing Service,
New Museums Site, Pembroke Street, Cambridge CB2 3QH, England.
Email:  nmm1 at cam.ac.uk
Tel.:  +44 1223 334761    Fax:  +44 1223 334679
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4