From 061b06a8ae2e49e7921080ea4a1cc157e704bb28 Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Sun, 9 Jan 2022 23:31:48 +0000 Subject: [PATCH] docs(rand): cherry-pick changes from rt update 0c0734d https://github.com/vim/vim/commit/0c0734d527a132edfb4089be48486586424b3f41 --- runtime/doc/builtin.txt | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt index 35beb97518..8d88c533f0 100644 --- a/runtime/doc/builtin.txt +++ b/runtime/doc/builtin.txt @@ -5534,16 +5534,17 @@ range({expr} [, {max} [, {stride}]]) *range()* < rand([{expr}]) *rand()* Return a pseudo-random Number generated with an xorshift - algorithm using seed {expr}. {expr} can be initialized by - |srand()| and will be updated by rand(). - If {expr} is omitted, an internal seed value is used and - updated. + algorithm using seed {expr}. The returned number is 32 bits, + also on 64 bits systems, for consistency. + {expr} can be initialized by |srand()| and will be updated by + rand(). If {expr} is omitted, an internal seed value is used + and updated. Examples: > :echo rand() :let seed = srand() :echo rand(seed) - :echo rand(seed) + :echo rand(seed) % 16 " random number 0 - 15 < Can also be used as a |method|: > seed->rand() @@ -7199,7 +7200,8 @@ sqrt({expr}) *sqrt()* srand([{expr}]) *srand()* Initialize seed used by |rand()|: - 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 {expr}. This is useful for testing or when a predictable sequence is expected.