Issue 112296

Summary: Rnd function incorrectly documents the arguments.
Product: documentation Reporter: andrew
Component: Online helpAssignee: Uwe Fischer <uwefis>
Status: CLOSED DUPLICATE QA Contact: issues@documentation <issues>
Severity: Trivial    
Priority: P3 CC: issues
Version: OOo 3.2.1   
Target Milestone: ---   
Hardware: All   
OS: All   
Issue Type: DEFECT Latest Confirmation in: ---
Developer Difficulty: ---

Description andrew 2010-06-11 01:49:11 UTC
Since OOo version 1.x, the help has always stated that the Rnd function accepts
an argument that influences what is returned by the function. To my knowledge,
this has never been true. A quick test to verify that a negative argument is
incorrectly documented is to run the following as part of a macro:

  Print Rnd(-2)
  Print Rnd(-2)
  Print Rnd(-2)
  Print Rnd(-2)

According to the documentation, the return value should be the same for each
call, and it is not. In fact, here is the source code:

RTLFUNC(Rnd)
{
    (void)pBasic;
    (void)bWrite;

	if ( rPar.Count() > 2 )
		StarBASIC::Error( SbERR_BAD_ARGUMENT );
	else
	{
		double nRand = (double)rand();
		nRand = ( nRand / (double)RAND_MAX );
		rPar.Get(0)->PutDouble( nRand );
	}
}

For those not versed in reading OOo source code. 

The first If checks if the number of arguments is greater than 2. if it is, then
generate an error. This really verifies that there is zero or one argument, but
I won't bother to explain why. If an argument were obtained, then you would see
a statement such as:

rPar.Get(1)->GetInteger()

Or something similar, but you do not.
Comment 1 Uwe Fischer 2010-06-14 11:51:09 UTC
Double to issue 73511

*** This issue has been marked as a duplicate of 73511 ***
Comment 2 Uwe Fischer 2010-06-14 11:51:35 UTC
closed as double