negative integer division

Grant Edwards grante at visi.com
Wed Feb 9 17:56:19 EST 2005


On 2005-02-09, Jive Dadson <jdadson at yahoo.com> wrote:

>> [C] isn't - it's a portable assembler.
>
> I've heard that many times, but it makes no sense to me.

I think the point is that C is a low-level, hardware twiddling
language to be used by people writing things like kernel code --
something that was always done in assembler before C came
along.

>> Now, I'll agree with you if you want to argue that some
>> machines do negative integer division in stupifyingly horrible
>> ways.
>
> That's why I think it was a stupifyingly horrible decision.

For a language meant to write user-space applications where one
probably cares what happens when a division results in a
negative integer, it is a horrible decision.  For a "portable
assembler" used to write device drivers it makes sense.  People
writing that sort of code presumably know how their hardware
behaves, don't expect that everything write is portable, and
just don't do division with negative numbers.  When they do
division, it's with postive numbers and they don't want to
waste the extra clock cycles to do it in a way that's
machine-independant for negative numbers.

The fact that C ended up in the rather inappropriate role of
a user-land application language is different problem.

-- 
Grant Edwards                   grante             Yow!  ... I think I'd
                                  at               better go back to my
                               visi.com            DESK and toy with a few
                                                   commonMISAPPREHENSIONS...



More information about the Python-list mailing list