From: Reinhard Meyer Date: Mon, 25 Apr 2005 11:04:23 +0200 Subject: AW: [U-Boot-Users] Compiler question: integer division? In-Reply-To: <426CA9EF.6080003@imc-berlin.de> Message-ID: List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de > How about > > a = b / 5; > ? > > Will that result in > > a = (b >> 2) - b; > > , i.e. still no division but only shift operations? I sincerely hope NOT! A = (B >> 2) - B = B/4 - B = -3/4 B IMHO, divisions by non-powers of two cannot be achieved by simple shifts and adds/subtracts in one formula - you'd always need conditional jumps and loop constructs. Reinhard