Last active
July 27, 2019 02:13
-
-
Save evan-moon/3183c2ebf9786b66645d5a9c435abb9d to your computer and use it in GitHub Desktop.
XOR Shift 128+ 난수 생성 알고리즘
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const state = [1827981275, 1295982171]; | |
function xorshift128plus () { | |
let s1 = state[0]; | |
let s0 = state[1]; | |
state[0] = s0; | |
s1 ^= s1 << 23; | |
s1 ^= s1 >> 17; | |
s1 ^= s0; | |
state[1] = s1; | |
console.log('레지스터의 현재 상태 -> ', state); | |
return state[0] + state[1]; | |
} | |
console.log('초기 레지스터 상태 -> ', state); | |
for (let i = 0; i < 5; i++) { | |
console.log('난수 -> ', xorshift128plus()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment