Integer math question

Elaine Jackson elainejackson7355 at home.com
Sun Jan 4 07:50:21 CET 2004


Sorry, I should have said "C rounds toward zero". In other words, the result of
casting x to integer type is sgn(x)*floor(abs(x)).

"Elaine Jackson" <elainejackson7355 at home.com> wrote in message
news:uEOJb.933787$pl3.753391 at pd7tw3no...
| C rounds toward the nearest integer and Python rounds down. The behavior is
| consistent in each case.
|
| "Frank" <mersmann at szut.uni-bremen.de> wrote in message
| news:3987e01c.0401030832.114c6f2a at posting.google.com...
| | Hi,
| |
| | can anybody help with the following problem?
| |
| | In C++
| |
| | i = 5 / 10 and
| | i = -5 / 10 both have the same result 0.
| |
| | In python
| |
| | i = 5 / 10 gives me 0 as expected, but
| | i = -5 / 10 gives -1 as result.
| |
| | Is this a feature or a bug? I remember Delphi gave me the same result as
| | C++.
| |
| | TIA,
| | Frank
|
|





More information about the Python-list mailing list