Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 (Tek) 9/28/84 based on 9/17/84; site hammer.UUCP Path: utzoo!watmath!clyde!burl!ulysses!bellcore!decvax!decwrl!pyramid!hplabs!tektronix!orca!hammer!seifert From: seifert@hammer.UUCP (Snoopy) Newsgroups: net.lang.c Subject: Re: integer division in ANSI C Message-ID: <1841@hammer.UUCP> Date: Tue, 4-Mar-86 14:46:28 EST Article-I.D.: hammer.1841 Posted: Tue Mar 4 14:46:28 1986 Date-Received: Fri, 7-Mar-86 06:06:24 EST References: <695@sftig.UUCP> Reply-To: tekecs!doghouse.TEK!snoopy (Snoopy) Distribution: net Organization: The Daisy Hill Puppy Farm Lines: 36 Summary: yet another proposal In article <695@sftig.UUCP> danny@sftig.UUCP (L.Rosler) writes: >System programmers really are not concerned about the behavior >when a negative number is involved. Except perhaps for -1, >negative numbers are considered harmful in this arena. The >goal of division is to get the positive quotient or positive >remainder as fast as the hardware can give it, and this will >always be hardware-independent. > >Application programmers, on the other hand, ARE concerned about >portable division involving negative numbers, a need which C >does not address. When this was discussed (at many Standards >meetings), the following positions emerged: > >1. Ignore the problem -- reliable application programs are > not important. >2. Force the compiler to generate code to produce portable > semantics -- fast systems programs are not important. [ various other options ] How about: case 1: (unsigned) / (unsigned) generates the positive quotient as fast as possible case 2: one or both are (signed) generates the correct signed quotient The compiler knows whether the integers are (signed) or (unsigned) at compile time, and can choose the appropriate code. Seems like this would satisfy both camps. Snoopy tektronix!tekecs!doghouse.TEK!snoopy