aboutsummaryrefslogtreecommitdiff
path: root/lmathlib.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2018-05-09 11:54:37 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2018-05-09 11:54:37 -0300
commit80bd4a89407fcba641f0ea53379e93523943ea6a (patch)
tree9744af6ffc8b868d0446d97cec41a084cbb57cb1 /lmathlib.c
parent3e7415e846f2f75ed29e27e1211205ea6243e0c7 (diff)
downloadlua-80bd4a89407fcba641f0ea53379e93523943ea6a.tar.gz
lua-80bd4a89407fcba641f0ea53379e93523943ea6a.tar.bz2
lua-80bd4a89407fcba641f0ea53379e93523943ea6a.zip
correction on xoshiro256** algorithm
(should use state[1] instead of state[0] for output)
Diffstat (limited to 'lmathlib.c')
-rw-r--r--lmathlib.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/lmathlib.c b/lmathlib.c
index 16b8a9cc..0dc8a35b 100644
--- a/lmathlib.c
+++ b/lmathlib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lmathlib.c,v 1.131 2018/04/06 17:52:42 roberto Exp roberto $ 2** $Id: lmathlib.c,v 1.132 2018/05/04 20:01:45 roberto Exp roberto $
3** Standard mathematical library 3** Standard mathematical library
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -304,7 +304,7 @@ static Rand64 rotl (Rand64 x, int n) {
304} 304}
305 305
306static Rand64 nextrand (Rand64 *state) { 306static Rand64 nextrand (Rand64 *state) {
307 Rand64 res = rotl(state[0] * 5, 7) * 9; 307 Rand64 res = rotl(state[1] * 5, 7) * 9;
308 Rand64 t = state[1] << 17; 308 Rand64 t = state[1] << 17;
309 state[2] ^= state[0]; 309 state[2] ^= state[0];
310 state[3] ^= state[1]; 310 state[3] ^= state[1];
@@ -427,7 +427,7 @@ static Rand64 rotl1 (Rand64 i, int n) {
427** implementation of 'xoshiro256**' algorithm on 'Rand64' values 427** implementation of 'xoshiro256**' algorithm on 'Rand64' values
428*/ 428*/
429static Rand64 nextrand (Rand64 *state) { 429static Rand64 nextrand (Rand64 *state) {
430 Rand64 res = times9(rotl(times5(state[0]), 7)); 430 Rand64 res = times9(rotl(times5(state[1]), 7));
431 Rand64 t = Ishl(state[1], 17); 431 Rand64 t = Ishl(state[1], 17);
432 Ixor(&state[2], state[0]); 432 Ixor(&state[2], state[0]);
433 Ixor(&state[3], state[1]); 433 Ixor(&state[3], state[1]);