summaryrefslogtreecommitdiff
path: root/doc/random_numbers.rst
blob: 2b87d5d44af8b09589321adc1b3d03f30306a4bf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
==============
Random numbers
==============

Function overview
=================

.. code-block:: c

	#include <libHX/misc.h>

	int HX_rand(void);
	unsigned int HX_irand(unsigned int min, unsigned int max);
	double HX_drand(double min, double max);

``HX_rand``
	Retrieve the next random number.

``HX_irand``
	Retrieve the next random number and fold it such that *min <= n < max*.

``HX_drand``
	Retrieve the next random number and fold it such that *min <= n < max*.

Implementation information
==========================

``/dev/urandom`` will be used to seed the libc-level number generator.

``/dev/random`` is not used on Linux because it may block during read, and
/dev/urandom is just as good when there is entropy available. If you need
definitive PRNG security, perhaps use one from a crypto suite such as OpenSSL.