summaryrefslogtreecommitdiff
path: root/scaddins
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2014-10-03 17:12:23 +0100
committerCaolán McNamara <caolanm@redhat.com>2014-10-06 14:13:27 +0100
commit8f436d3de7e99268a8862664d2cb2574231c3b18 (patch)
tree0a07dd3cecbd7bc5b0293006bb8691e33c5cca75 /scaddins
parente5ab3685550cf35c3eb9cb47530044f2d86433d5 (diff)
use comphelper::rng::uniform_*_distribution everywhere
and automatically seed from time on first use coverity#1242393 Don't call rand coverity#1242404 Don't call rand coverity#1242410 Don't call rand and additionally allow 0xFF as a value coverity#1242409 Don't call rand coverity#1242399 Don't call rand coverity#1242372 Don't call rand coverity#1242377 Don't call rand coverity#1242378 Don't call rand coverity#1242379 Don't call rand coverity#1242382 Don't call rand coverity#1242383 Don't call rand coverity#1242402 Don't call rand coverity#1242397 Don't call rand coverity#1242390 Don't call rand coverity#1242389 Don't call rand coverity#1242388 Don't call rand coverity#1242386 Don't call rand coverity#1242384 Don't call rand coverity#1242394 Don't call rand Change-Id: I241feab9cb370e091fd6ccaba2af941eb95bc7cf
Diffstat (limited to 'scaddins')
-rw-r--r--scaddins/idl/com/sun/star/sheet/addin/XAnalysis.idl2
-rw-r--r--scaddins/source/analysis/analysis.cxx9
2 files changed, 5 insertions, 6 deletions
diff --git a/scaddins/idl/com/sun/star/sheet/addin/XAnalysis.idl b/scaddins/idl/com/sun/star/sheet/addin/XAnalysis.idl
index e349284e97a2..4622f2acefb6 100644
--- a/scaddins/idl/com/sun/star/sheet/addin/XAnalysis.idl
+++ b/scaddins/idl/com/sun/star/sheet/addin/XAnalysis.idl
@@ -109,6 +109,8 @@ module addin
raises( com::sun::star::lang::IllegalArgumentException );
// randbetween.
+ // Min is the smallest value randbetween will return
+ // Max is the largest value randbetween will return
double getRandbetween( [in] double Min, [in] double Max )
raises( com::sun::star::lang::IllegalArgumentException );
diff --git a/scaddins/source/analysis/analysis.cxx b/scaddins/source/analysis/analysis.cxx
index 6349b7b27247..d1751f4fac40 100644
--- a/scaddins/source/analysis/analysis.cxx
+++ b/scaddins/source/analysis/analysis.cxx
@@ -22,6 +22,7 @@
#include "bessel.hxx"
#include <cppuhelper/factory.hxx>
#include <comphelper/processfactory.hxx>
+#include <comphelper/random.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <osl/diagnose.h>
#include <rtl/ustrbuf.hxx>
@@ -30,6 +31,7 @@
#include <string.h>
#include <tools/resmgr.hxx>
#include <tools/rcid.h>
+#include <boost/math/special_functions/next.hpp>
#define ADDIN_SERVICE "com.sun.star.sheet.AddIn"
#define MY_SERVICE "com.sun.star.sheet.addin.Analysis"
@@ -700,12 +702,7 @@ double SAL_CALL AnalysisAddIn::getRandbetween( double fMin, double fMax ) throw(
if( fMin > fMax )
throw lang::IllegalArgumentException();
- // fMax -> range
- double fRet = fMax - fMin + 1.0;
- fRet *= rand();
- fRet /= (RAND_MAX + 1.0);
- fRet += fMin;
- fRet = floor( fRet ); // simple floor is sufficient here
+ double fRet = comphelper::rng::uniform_real_distribution(fMin, boost::math::nextafter(fMax, DBL_MAX));
RETURN_FINITE( fRet );
}