random number generators for calc

Markus Mohrhard markus.mohrhard at googlemail.com
Fri Dec 7 08:04:52 PST 2012

Hey Tino,

2012/12/6 tino <ttk448 at gmail.com>:
>> > just happened to reimplement RAND() with a B.A Wichmann
>> > and I.D Hill generator.. see
>>       As they are entitled to. No doubt we'll come up with a comprehensive,
>> nicely architected and beautiful solution of our own :-)
> Ok, I'll go ahead with a suggestion then. :)
> Attached patch is just a simple wrapper around boost, to be used like
> sc::rng::seed() to replace libc srand()
> sc::rng::rand() to replace libc rand()
> and a few more distributions.
> I've also modified ScInterpreter::ScRandom()
> to simply call sc::rng::uniform()
> which should solve bug 33365.
> I've not modified RANDBETWEEN(a,b) yet but this could simply call
> sc::rng::uniform_int(a,b).
> Also, the rand in Basic could be changed in the future.
> Small problems:
>  - compiler warnings from within boost

We need to patch them out otherwise the Werror build will fail. It
seems that these warnings are also fixed upstream.

>  - few asserts might need to be replaced

asserts are fine in the code. They are only used in debug and dbgutil
builds, so will normally not show up in releases but helpt to find
bugs earlier.

Just a few more comments about the patch. We need to ifdef all unused
methods in random.[ch]xx otherwise they will be removed in nearly no
time. We are removing unused functions to clean the codebase. Please
also don't leave old code commented, we have git for code history so
we don't need to keep all code as comments. Before I'll push the
change with these modifications I'll check with a big file containing
a lot of RANDOM functions to check that we are not introducing a
performance regression.


More information about the LibreOffice mailing list