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 <mene...@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
_______________________________________________
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice