Please, have a look at this patch. On my Linux system it seems to work
fine. Here is the issue it could fix:
http://qa.openoffice.org/issues/show_bug.cgi?id=116920 - "Sometimes RND
returns 1 (one)" .
Here is how the code should look after the patch is applied:
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 + 1.0));
rPar.Get(0)->PutDouble( nRand );
}
}
(Changes if they are accepted are LGPLv3/MPL)
From 858a00fb247937fcba6bce32b376d52e5076831f Mon Sep 17 00:00:00 2001
From: Clio <menenem@bk.ru>
Date: Mon, 14 Feb 2011 13:02:09 -0400
Subject: [PATCH] IZ #116920 RND returns one fix
---
basic/source/runtime/methods.cxx | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx
index ce96f66..039c5d6 100644
--- a/basic/source/runtime/methods.cxx
+++ b/basic/source/runtime/methods.cxx
@@ -3446,7 +3446,7 @@ RTLFUNC(Rnd)
else
{
double nRand = (double)rand();
- nRand = ( nRand / (double)RAND_MAX );
+ nRand = ( nRand / ((double)RAND_MAX + 1.0));
rPar.Get(0)->PutDouble( nRand );
}
}
--
1.7.0.4
Context
- [Libreoffice] [PATCH] need review: fix for #116920 · Clio
Privacy Policy |
Impressum (Legal Info) |
Copyright information: Unless otherwise specified, all text and images
on this website are licensed under the
Creative Commons Attribution-Share Alike 3.0 License.
This does not include the source code of LibreOffice, which is
licensed under the Mozilla Public License (
MPLv2).
"LibreOffice" and "The Document Foundation" are
registered trademarks of their corresponding registered owners or are
in actual use as trademarks in one or more countries. Their respective
logos and icons are also subject to international copyright laws. Use
thereof is explained in our
trademark policy.