[U-Boot-Users] Compiler question: integer division?

Udi Finkelstein u-boot-users at udif.com
Mon Apr 25 16:31:33 CEST 2005


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




More information about the U-Boot mailing list