From mboxrd@z Thu Jan 1 00:00:00 1970 From: Udi Finkelstein Date: Mon, 25 Apr 2005 17:31:33 +0300 Subject: [U-Boot-Users] Compiler question: integer division? In-Reply-To: <426CA9EF.6080003@imc-berlin.de> References: <42692C53.1020305@imc-berlin.de> <42693021.7090908@smiths-aerospace.com> <42693193.9070300@imc-berlin.de> <426CA9EF.6080003@imc-berlin.de> Message-ID: <426CFF45.6000402@udif.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Steven Scholz wrote: > How about > > a = b / 5; > ? > > Will that result in > > a = (b >> 2) - b; > > , i.e. still no division but only shift operations? > I must be missing something here, because as far as I can see, the shift/substract combination above does not yield the same result as dividing by 5. Using b=40 for example: b/5 -> 8 (b >> 2) - b -> -30 Udi