Rockbox.org home
release
dev builds
extras
themes manual
wiki
device status forums
mailing lists
IRC bugs
patches
dev guide



Rockbox mail archive

Subject: Re: Rockbox Digest, Vol 18, Issue 9

Re: Rockbox Digest, Vol 18, Issue 9

From: Ray Lambert <listlizard_at_interthingy.net>
Date: 2005-07-06

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/rockbox
Received on Wed Jul 6 21:54:51 2005

Page was last modified "Jan 10 2012" The Rockbox Crew
aaa