To comment on the following update, log in, then open the issue:
http://www.openoffice.org/issues/show_bug.cgi?id=116920


User bormant changed the following:

                What    |Old value                 |New value
================================================================================
              OS/Version|All                       |Windows, all
--------------------------------------------------------------------------------




------- Additional comments from borm...@openoffice.org Sun Feb 13 12:08:43 
+0000 2011 -------
I can not reproduce this bug on 32-bit linux biulds of OOo (tested on Slackware-
13.1, Fedora-14, Ubuntu-10.04).
So, OS field has been changed to Windows.

I can not agree that the problem is OS, not the OOo build for Windows.

The Linux Programmers Guide says that the rand() function returns a pseudo-
random integer in the range [0, RAND_MAX]. MSDN has similar description.

Current OOo Basic RND implementation doesn't contain any differences for 
Win/Lin:

basic/source/runtime/methods.cxx

 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 );
        }
}

So, the only reason is used C/C++ compiler runtime: rand() returns [0;RAND_MAX) 
on Linux and [0;RAND_MAX] on Windows.

May be (quick and dirty)

#IFDEF (<something_unique_for_this_win_compiler>)
                // srand() returns [0;RAND_MAX]
                nRand = ( nRand / ((double)RAND_MAX + 1.));
#ELSE
                // srand() returns [0;RAND_MAX)
                nRand = ( nRand / (double)RAND_MAX );
#ENDIF

32766/32767 = 0,999969481
32766/32768 = 0,999938965
32767/32768 = 0,999969482

And if we can agree with maximum RND values 0,999938965 on Linux and 
0,999969482 
on Windows, too more dirty:

                nRand = ( nRand / ((double)RAND_MAX + 1.));


---------------------------------------------------------------------
Please do not reply to this automatically generated notification from
Issue Tracker. Please log onto the website and enter your comments.
http://qa.openoffice.org/issue_handling/project_issues.html#notification

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@script.openoffice.org
For additional commands, e-mail: issues-h...@script.openoffice.org


---------------------------------------------------------------------
To unsubscribe, e-mail: allbugs-unsubscr...@openoffice.org
For additional commands, e-mail: allbugs-h...@openoffice.org

Reply via email to