delorie.com/archives/browse.cgi | search |
From: | horst DOT kraemer AT snafu DOT de (Horst Kraemer) |
Newsgroups: | comp.os.msdos.djgpp |
Subject: | Re: DJGPP division optimisations |
Date: | Tue, 14 Jul 1998 10:19:31 GMT |
Organization: | Unlimited Surprise Systems, Berlin |
Message-ID: | <35ab1f95.79373671@news.snafu.de> |
References: | <35AA8994 DOT 3FC1 AT virgin DOT net> <6oe4in$1m7$1 AT rosenews DOT rose DOT hp DOT com> <35AAA705 DOT 1BDE AT cam DOT org> |
NNTP-Posting-Host: | n31-172.berlin.snafu.de |
Lines: | 17 |
To: | djgpp AT delorie DOT com |
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
On Mon, 13 Jul 1998 20:32:05 -0400, Vic <tudor AT cam DOT org> wrote: >it's true, I checked this. I put "unsigned" in front of the variables >and the 2 loops performed the same (2.74 seconds) And the reason is clear. The operations x/2 and x>>1 are different if x is a negative number. As you declared x to be a signed type the compiler may not "pessimize" /2 to >>1. It doesn't know when compiling that x will never be negative. int i = -1; printf("%d %d\n", i/2 , i>>1 ); Regards Horst
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |