AW: [U-Boot-Users] Compiler question: integer division?
Reinhard Meyer
reinhard.meyer at emk-elektronik.de
Mon Apr 25 11:04:23 CEST 2005
> 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
More information about the U-Boot
mailing list