Introduction
Introduction Statistics Contact Development Disclaimer Help
zrand.3 - libzahl - big integer library
git clone git://git.suckless.org/libzahl
Log
Files
Refs
README
LICENSE
---
zrand.3 (2219B)
---
1 .TH ZRAND 3 libzahl
2 .SH NAME
3 zrand - Generate random a number
4 .SH SYNOPSIS
5 .nf
6 #include <zahl.h>
7
8 void zrand(z_t \fIr\fP, enum zranddev \fIdev\fP, enum zranddist \fIdist\…
9 .fi
10 .SH DESCRIPTION
11 .B zrand
12 generates a random number and stores it in
13 .IR r .
14 .P
15 .I dev
16 selects the device
17 .B zrand
18 uses to generate random bits.
19 This value may be either of:
20 .TP
21 .B DEFAULT_RANDOM
22 This is a version-dependent alias for the
23 default random number generator. That is,
24 using this option will cause
25 .B zrand
26 to select the default random number generator.
27 Which random number generator is actually
28 selected may change between versions of
29 .B zrand.
30
31 The selection will be a balance between randomness
32 and performance.
33 .TP
34 .B FASTEST_RANDOM
35 This is a version-dependent alias for the
36 fastest random number generator. That is,
37 using this option will cause
38 .B zrand
39 to select the fastest random number generator.
40 Which random number generator is actually
41 selected may change between versions of
42 .B zrand.
43 .TP
44 .B FAST_RANDOM
45 The fast, non-blocking random number generator.
46 This is /dev/urandom on Linux.
47 .TP
48 .B SECURE_RANDOM
49 The secure, blocking random number generator.
50 This is /dev/random on Linux.
51 .P
52 .I dist
53 selects the probably distribution of the
54 output
55 .IR r :
56 .TP
57 .B QUASIUNIFORM
58 Use the method of generation that is often
59 recommended for generating uniformally random
60 integers. This method has unnecessary
61 computational overhead and is not properly
62 uniform, but is is guaranteed to run in
63 constant time assuming the underlying device
64 for random bit generation does.
65
66 The generated number if be in the inclusive
67 range [0,
68 .IR max ].
69 .TP
70 .B UNIFORM
71 Generate a integer in the range [0,
72 .IR max ]
73 uniformally random.
74 .TP
75 .B MODUNIFORM
76 Slightly faster alternative to
77 .BR UNIFORM .
78
79 It is not truly uniform. It is biased
80 to the lower numbers, but the probably
81 if any number is either
82 .I p
83 or
84 .I 2p
85 for some parameter-dependent number
86 .IR p .
87
88 It uses the naïve approach of generating
89 a random number and modulation with the maximum
90 number. However, this implementation this
91 modulation by subtracting with the maximum number
92 if the generated number is greater.
93 .P
94 It is safe to call
95 .B zrand
96 with non-unique parameters.
You are viewing proxied material from suckless.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.