From: ams AT ludd DOT luth DOT se (Martin Str|mberg) Newsgroups: comp.os.msdos.djgpp Subject: Re: gcc optimizes divisons! Date: 23 Sep 1999 19:37:54 GMT Organization: University of Lulea, Sweden Lines: 32 Message-ID: <7sdvii$ipb$1@news.luth.se> References: <37e37095 AT news DOT xenologics DOT com> <7scukd$rm6$1 AT antares DOT lu DOT erisoft DOT se> <37ea6cda AT news DOT xenologics DOT com> NNTP-Posting-Host: queeg.ludd.luth.se X-Newsreader: TIN [UNIX 1.3 950824BETA PL0] To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Oliver Roese (oroese AT edina DOT xnc DOT com) wrote: : : Martin Stromberg schrieb in im Newsbeitrag: : 7scukd$rm6$1 AT antares DOT lu DOT erisoft DOT se... : (...) : > : > Well... Obviously(?) x/3 == 1431655766*x + (x<0?1:0) (mod 2^32) : > Or perhaps (mod 2^32) should be (mod 2^31)... : > : > It's very probably mathematically provable using rings and fields and : such. : > : : The above equation cannot hold, since x/3 is fractional most of the : time. You are missing the fact that we are operating on the ring Z(2^32), so the mapping is Z(2^32) -> Z(2^32) on the division operation, where /3 is a special case. : Even if this was a mistake and you meant floor(x/3), the equation cannot : hold, since : floor(x/n) is a staircase function. floor() is something which operates on R or (in computers) floating point. We are dealing with integers here (and in this case, a subset of them, Z(2^32)). Right, MartinS