summaryrefslogtreecommitdiff
path: root/basic/source/runtime/methods.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'basic/source/runtime/methods.cxx')
-rw-r--r--basic/source/runtime/methods.cxx13
1 files changed, 6 insertions, 7 deletions
diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx
index fe2f00d3a178..2e3c375699b2 100644
--- a/basic/source/runtime/methods.cxx
+++ b/basic/source/runtime/methods.cxx
@@ -45,6 +45,7 @@
#include "errobject.hxx"
#include <comphelper/processfactory.hxx>
+#include <comphelper/random.hxx>
#include <comphelper/string.hxx>
#include <com/sun/star/uno/Sequence.hxx>
@@ -3521,16 +3522,16 @@ RTLFUNC(Randomize)
{
StarBASIC::Error( SbERR_BAD_ARGUMENT );
}
- sal_Int16 nSeed;
+ int nSeed;
if( rPar.Count() == 2 )
{
- nSeed = (sal_Int16)rPar.Get(1)->GetInteger();
+ nSeed = (int)rPar.Get(1)->GetInteger();
}
else
{
- nSeed = (sal_Int16)rand();
+ nSeed = (int)time(NULL);
}
- srand( nSeed );
+ comphelper::rng::seed( nSeed );
}
RTLFUNC(Rnd)
@@ -3544,9 +3545,7 @@ RTLFUNC(Rnd)
}
else
{
- double nRand = (double)rand();
- nRand = ( nRand / ((double)RAND_MAX + 1.0));
- rPar.Get(0)->PutDouble( nRand );
+ rPar.Get(0)->PutDouble( comphelper::rng::uniform() );
}
}