• Subject: Re: Help with an algorithm
• From: Tim Hill <drtimhill@...>
• Date: Sat, 25 May 2013 12:08:49 -0700

```On most platforms these days unsigned long is 64 bits (however, note the "most").

On May 25, 2013, at 8:33 AM, Steve Litt <slitt@troubleshooters.com> wrote:

> On Sat, 25 May 2013 14:33:18 +1000
> Vaughan McAlley <vaughan@mcalley.net.au> wrote:
>
>> On 25 May 2013 01:28, Steve Litt <slitt@troubleshooters.com> wrote:
>>> On Fri, 24 May 2013 17:20:40 +1000
>
> [clip]
>
>>> One comment about all the algorithms delivering the next number
>>> with Y number of 1's: I'm pretty sure those work on the natural
>>> hardware size of numbers on a given computer, so unless your
>>> hardware has 40 bit integers, I don't think those will work, at
>>> least not without some modification.
>>>
>>> One more thing -- make sure your computer has plenty of cooling
>>> capacity. My prime number generator got my CPU up to 86 Celsius in
>>> maybe 5 minutes.
>>>
>>> SteveT
>>>
>>> Steve Litt                *  http://www.troubleshooters.com/
>>> Troubleshooting Training  *  Human Performance
>>>
>>
>> In the end I used the snoob function from
>> http://www.hackersdelight.org/basics2.pdf adapted like this:
>>
>> unsigned long snoob(unsigned long x)
>> {
>>    unsigned long smallest, ripple, ones;
>>
>>    smallest = x & -x;
>>    ripple = x + smallest;
>>    ones = x ^ ripple;
>>    ones = (ones >> 2)/smallest;
>>    return ripple | ones;
>> }
>>
>> I got over my fear of Xcode (the Raspberry Pi is only 32 bits so would
>> have taken much longer), and my iMac chugged through the 40 billion
>> numbers in a few hours. Luckily I wasn’t trying to store all the
>> numbers, just find the most interesting.
>>
>> Working with 64-bit numbers is a bit trickier than 32-bit numbers...
>>
>> Vaughan
>
> Vaughan,
>
> Where in the program did you tell it you're using 40 bit numbers? Or
> did you just quit when you reached
>
> 0000000000000000000000000000000000000001111111111111110000000000000000000000000
>
> ?
>
> Did you find any evidence of your computer CPU overheating?
>
> What properties made some of these numbers more interesting than
> others? Did you use pipes like:
>
> ./find_fifteens | ./show_interesting.sh > interesting_numbers.txt
>
> These are the times I love computers. I might do this myself.
>
> Thanks,
>
> SteveT
>
> Steve Litt                *  http://www.troubleshooters.com/
> Troubleshooting Training  *  Human Performance
>

```