Skip to content

improve random

Reference issue

Fixes #2749 (closed)

What does this implement/fix?

Currently, one call of std::rand is used to provide the target scalar with random bits. This appears to work well enough for 32 bit scalars if RAND_MAX is equal to INT_MAX, but this is not the case on MSVC. This is insufficient on most platforms if the target scalar is 64 bits.

This implementation calls std::rand as many times as necessary to fill the target scalar with the required entropy. For integers, this is the entire scalar. For floating points, this is equal to the mantissa bits.

Additional information

Edited by Charles Schlosser

Merge request reports

Loading