]> sourceware.org Git - lvm2.git/commit
Don't use floor() in _bitset_with_random_bits
authorZdenek Kabelac <zkabelac@redhat.com>
Wed, 13 Oct 2010 12:18:53 +0000 (12:18 +0000)
committerZdenek Kabelac <zkabelac@redhat.com>
Wed, 13 Oct 2010 12:18:53 +0000 (12:18 +0000)
commit919568a223b8227158394a7a92dbf08af5edc267
treee1876c0a69ecb75b159fa01c82b33848d78d23a0
parentec81f7151d23ec2430ad27575450a197c104e620
Don't use floor() in _bitset_with_random_bits

Use _even_rand() function instead of floor() in _bitset_with_random_bits().
floor() function is missing in dietlibc (on architectures other than x86).
Moreover using floor() to clip rand results does not assure even result
distribution. _even_rand() uses integer arithmetic only and is designed to
return evenly distributed results.

> Looks OK to me. It took a while to decipher what is the exact meaning of
> the loop in _even_rand (to a non-pseudorandomness-expert) but I am
> fairly comfortable with it now. If I understand this correctly, it
> rejects numbers that come from an "incomplete" slice of the RAND_MAX
> space (considering the number space [0, RAND_MAX] is divided into some
> "max"-sized slices and at most a single smaller slice, between [n*max,
> RAND_MAX] for suitable n -- numbers from this last slice are discarded
> because they could distort the distribution in favour of smaller
> numbers).

Signed-off-by: Przemyslaw Iskra <sparky <at> pld-linux.org>
Reviewed-by: Petr Rockai <prockai <at> redhat.com>
configure.in
lib/metadata/metadata.c
lib/misc/configure.h.in
This page took 0.037343 seconds and 5 git commands to generate.