comparison runtime/doc/eval.txt @ 18732:2513e666aa82 v8.1.2356

patch 8.1.2356: rand() does not use the best algorithm Commit: https://github.com/vim/vim/commit/f8c1f9200c4b50969a8191a4fe0b0d09edb38979 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Nov 28 22:13:14 2019 +0100 patch 8.1.2356: rand() does not use the best algorithm Problem: rand() does not use the best algorithm. Solution: use xoshiro128** instead of xorshift. (Kaito Udagawa, closes #5279)
author Bram Moolenaar <Bram@vim.org>
date Thu, 28 Nov 2019 22:15:04 +0100
parents 99586852c2db
children 8dde7ced3344
comparison
equal deleted inserted replaced
18731:e55bced76a31 18732:2513e666aa82
1 *eval.txt* For Vim version 8.1. Last change: 2019 Nov 25 1 *eval.txt* For Vim version 8.1. Last change: 2019 Nov 28
2 2
3 3
4 VIM REFERENCE MANUAL by Bram Moolenaar 4 VIM REFERENCE MANUAL by Bram Moolenaar
5 5
6 6
7639 Can also be used as a |method|: > 7639 Can also be used as a |method|: >
7640 GetExpr()->range() 7640 GetExpr()->range()
7641 < 7641 <
7642 7642
7643 rand([{expr}]) *rand()* 7643 rand([{expr}]) *rand()*
7644 Return a pseudo-random Number generated with an xorshift 7644 Return a pseudo-random Number generated with an xoshiro128**
7645 algorithm using seed {expr}. The returned number is 32 bits, 7645 algorithm using seed {expr}. The returned number is 32 bits,
7646 also on 64 bits systems, for consistency. 7646 also on 64 bits systems, for consistency.
7647 {expr} can be initialized by |srand()| and will be updated by 7647 {expr} can be initialized by |srand()| and will be updated by
7648 rand(). If {expr} is omitted, an internal seed value is used 7648 rand(). If {expr} is omitted, an internal seed value is used
7649 and updated. 7649 and updated.
9148 9148
9149 9149
9150 srand([{expr}]) *srand()* 9150 srand([{expr}]) *srand()*
9151 Initialize seed used by |rand()|: 9151 Initialize seed used by |rand()|:
9152 - If {expr} is not given, seed values are initialized by 9152 - If {expr} is not given, seed values are initialized by
9153 time(NULL) a.k.a. epoch time. This only has second 9153 reading from /dev/urandom, if possible, or using time(NULL)
9154 accuracy. 9154 a.k.a. epoch time otherwise; this only has second accuracy.
9155 - If {expr} is given, return seed values which x element is 9155 - If {expr} is given it must be a Number. It is used to
9156 {expr}. This is useful for testing or when a predictable 9156 initialize the seed values. This is useful for testing or
9157 sequence is expected. 9157 when a predictable sequence is intended.
9158 9158
9159 Examples: > 9159 Examples: >
9160 :let seed = srand() 9160 :let seed = srand()
9161 :let seed = srand(userinput) 9161 :let seed = srand(userinput)
9162 :echo rand(seed) 9162 :echo rand(seed)