View | Details | Raw Unified | Return to issue 121421
Collapse All | Expand All

(-)main/sc/source/core/tool/interpr1.cxx (-1 / +22 lines)
Lines 86-91 Link Here
86
// Funktionen
86
// Funktionen
87
//-----------------------------------------------------------------------------
87
//-----------------------------------------------------------------------------
88
88
89
// Initial seed for the Wichman-Hill 2006 RNG.
90
// Still have to find a way to generate long ints from rand()
91
static long int ix =  123456789L,
92
		iy =  345678901L,
93
		iz =  123456789L,
94
		it =  789012345L;
89
95
90
void ScInterpreter::ScIfJump()
96
void ScInterpreter::ScIfJump()
91
{
97
{
Lines 1542-1548 Link Here
1542
void ScInterpreter::ScRandom()
1548
void ScInterpreter::ScRandom()
1543
{
1549
{
1544
    RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", "ScInterpreter::ScRandom" );
1550
    RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", "ScInterpreter::ScRandom" );
1545
    PushDouble((double)rand() / ((double)RAND_MAX+1.0));
1551
1552
    // P-RNG for Wichman-Hill 2006.
1553
    ix = 11600L * (ix % 185127L) - 10379L * (ix / 185127L);
1554
    iy = 47003L * (iy % 45688L) - 10479L * (iy / 45688L);
1555
    iz = 23000L * (iz % 93368L) - 8123L * (it / 93368L);
1556
    it = 23000L * (it % 65075L) - 8123L * (it / 65075L);
1557
    if (ix < 0)
1558
	ix += 2147483579L;
1559
    if (iy < 0)
1560
	iy += 2147483543L;
1561
    if (iz < 0)
1562
	it += 2147483123L;
1563
    W = ((double)ix / 2147483579.0 + (double)iy / 2147483543.0 +
1564
	(double)iz / 2147483423.0 + (double)it / 2147483123.0);
1565
1566
    PushDouble(W - (long)W);
1546
}
1567
}
1547
1568
1548
1569

Return to issue 121421