|
Rockbox mail archiveSubject: Re: Rockbox Digest, Vol 18, Issue 9Re: Rockbox Digest, Vol 18, Issue 9
From: Ray Lambert <listlizard_at_interthingy.net>
Date: Wed, 06 Jul 2005 15:58:25 +0000 BlueChip wrote: > while (x>0) r = (r<<3)+(r<<1); // r*8 + r*2 > ^whoops > > > At 19:52 06/07/2005, you wrote: > >> what values of 'x' ? all positive? include 0? >> >> if (x<0) return(0); // cannot handle negative values of x >> if (x>9) return(-1); // result will be > (2^32)-1 >> unsigned long r = 1; >> while (x>0) r = (r<<4)+(r<<1); // r*8 + r*2 >> return (r); > It might be a good idea to decrement x at some point too.... :) > while (x>0) r = (r<<3)+(r<<1); // r*8 + r*2 perhaps: for (; x>0; --x) r = (r<<3)+(r<<1); // r*8 + r*2 ~ray -- #b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b "The music business is a cruel and shallow money trench, a long plastic hallway where thieves and pimps run free, and good men die like dogs ....... There's also a negative side." -- Hunter S. Thompson #b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b _______________________________________________ http://cool.haxx.se/mailman/listinfo/rockboxReceived on 2005-07-06 Page template was last modified "Tue Sep 7 00:00:02 2021" The Rockbox Crew -- Privacy Policy |