negative integer division

Mike Meyer mwm at mired.org
Tue Feb 8 22:35:50 EST 2005


Jive Dadson <jdadson at yahoo.com> writes:

> Python does it right.  C is allowed to do it anyway it likes, which was
> a stupifyingly horrible decision, IMHO.

C only does it wrong if you think that C is a high level language. It
isn't - it's a portable assembler. As such, low level things (like
this, or what happens on integer overflow, or ...) are left up to the
implementation, so it can do what's most natural for the underlying
hardware. This means that when you don't care - which I'd argue is
most of the time - you get the fastest thing the machine will do. When
you do care, you have to take care of it yourself. Of course, if you
care, you probably shouldn't be writing in assembler, you should
probably be writing in a high level language - which will make sure
the low level things get done right, irregardless of what the
underlying machine does.

Now, I'll agree with you if you want to argue that some machines do
negative integer division in stupifyingly horrible ways.

         <mike
-- 
Mike Meyer <mwm at mired.org>			http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.



More information about the Python-list mailing list