|
 |
I tried it myself with the program at the end of this post, and got a
bit different of a result. The program printed:
times tested: 100000000, sum: 1600092924, average: 16.0009
times tested: 200000000, sum: 2952473665, average: 14.7624
times tested: 300000000, sum: 4316535702, average: 14.3885
times tested: 400000000, sum: 6018669380, average: 15.0467
times tested: 500000000, sum: 7585216727, average: 15.1704
times tested: 600000000, sum: 8915924298, average: 14.8599
times tested: 700000000, sum: 10662688388, average: 15.2324
times tested: 800000000, sum: 12027713479, average: 15.0346
times tested: 900000000, sum: 13468996092, average: 14.9656
times tested: 1000000000, sum: 15300481793, average: 15.3005
The program:
#include "IsaacRand.hh"
#include <iostream>
#include <cassert>
int main()
{
typedef unsigned long long ULL;
IsaacRand rng(0);
ULL sum = 0;
std::cout << "sizeof(sum) = " << sizeof(sum) << std::endl;
ULL counter;
for(counter = 0; counter < 1000000000ULL; ++counter)
{
ULL rounds = 0;
while(rng.getNext() % 2 == 0)
{
++rounds;
assert(rounds < 64);
}
if(rounds) sum += 1ULL << rounds;
else ++sum;
if(counter % 100000000 == 100000000-1)
std::cout << "times tested: " << counter+1
<< ", sum: " << sum << ", average: "
<< double(sum)/double(counter) << std::endl;
}
}
Post a reply to this message
|
 |