docs(rand): cherry-pick changes from rt update 0c0734d

0c0734d527
This commit is contained in:
Sean Dewar 2022-01-09 23:31:48 +00:00
parent f6a0d5498b
commit 061b06a8ae
No known key found for this signature in database
GPG Key ID: 08CC2C83AD41B581

View File

@ -5534,16 +5534,17 @@ range({expr} [, {max} [, {stride}]]) *range()*
< <
rand([{expr}]) *rand()* rand([{expr}]) *rand()*
Return a pseudo-random Number generated with an xorshift Return a pseudo-random Number generated with an xorshift
algorithm using seed {expr}. {expr} can be initialized by algorithm using seed {expr}. The returned number is 32 bits,
|srand()| and will be updated by rand(). also on 64 bits systems, for consistency.
If {expr} is omitted, an internal seed value is used and {expr} can be initialized by |srand()| and will be updated by
updated. rand(). If {expr} is omitted, an internal seed value is used
and updated.
Examples: > Examples: >
:echo rand() :echo rand()
:let seed = srand() :let seed = srand()
:echo rand(seed) :echo rand(seed)
:echo rand(seed) :echo rand(seed) % 16 " random number 0 - 15
< <
Can also be used as a |method|: > Can also be used as a |method|: >
seed->rand() seed->rand()
@ -7199,7 +7200,8 @@ sqrt({expr}) *sqrt()*
srand([{expr}]) *srand()* srand([{expr}]) *srand()*
Initialize seed used by |rand()|: Initialize seed used by |rand()|:
- If {expr} is not given, seed values are initialized by - If {expr} is not given, seed values are initialized by
time(NULL) a.k.a. epoch time. time(NULL) a.k.a. epoch time. This only has second
accuracy.
- If {expr} is given, return seed values which x element is - If {expr} is given, return seed values which x element is
{expr}. This is useful for testing or when a predictable {expr}. This is useful for testing or when a predictable
sequence is expected. sequence is expected.