[Tfug] Byte Order

Robert Hunter hunter at tfug.org
Fri Nov 17 12:37:36 MST 2006


> but tried to keep the code somewhat readable
> (yeah, except for that power-of-two business...)

Rich, here is a trick you can use in C. Multiplying or dividing by two is
equivalent to bit-shifting.

e.g.

2*2*2*2*2*2*2*2*2*2 == 1024 == 1 << 10

1024/2/2/2/2/2/2/2/2/2/2 == 1 == 1024 >> 10




-- 
Rob




More information about the tfug mailing list