#include <cstdlib>

#include "mathfunc.h"

#ifdef _DEBUG
#ifndef DEBUG_NEW
#define DEBUG_NEW new(_NORMAL_BLOCK, __FILE__, __LINE__)
#define new DEBUG_NEW
#endif
#endif

// --------------------------------

unsigned long long seed = 0;

// --------------------------------

unsigned long long random(void)
{
    return seed = 6364136223846793005 * seed + 1442695040888963407;
}

// --------------------------------

double rand01(void) 
{
    /*double r = 0.0L;
    double b = 1.0L;
    unsigned long long i = random();
    while (i) {
        b *= 0.5L;
        if (i % 2)
            r += b;
        i /= 2;
    }*/

    return double(rand()) / double(RAND_MAX);
/*
    return r;
*/
}

// --------------------------------