Good xorshift, Bad xorshift

| ← back |
| home |

Good xorshift parameters

FreeBASIC graphical xorshift test program
/' (c) 2021 cepstrum.co.jp '/
' FreeBASIC GUI program
' >fbc -s gui
'--------------------------------------------------------------------------
' xorshift random number generator

function uint_xorshift(a as uinteger, b as uinteger, c as uinteger) as uinteger<32>
  static r as uinteger<32> = &Hffffffff

  r=r xor (r shl a)
  r=r xor (r shr b)
  r=r xor (r shl c)
  return r
end function

'--------------------------------------------------------------------------

dim x    as uinteger
dim y    as uinteger
dim dotc as uinteger
dim a    as uinteger = 5
dim b    as uinteger = 17
dim c    as uinteger = 13
dim shft as uinteger = 1

screenres 1024, 1024

sleep 300
while inkey$<>""
wend

while inkey$=""
  x   =(uint_xorshift(a, b, c) shr shft) mod 1024
  y   =(uint_xorshift(a, b, c) shr shft) mod 1024
  dotc=(uint_xorshift(a, b, c) shr shft) mod 64
  line (x, y)-(x, y), dotc
wend


Test results

Program download

xorshift_3_13_7.exe

xorshift_1_5_16.exe xorshift_1_19_3.exe xorshift_1_21_20.exe xorshift_1_27_27.exe xorshift_2_7_7.exe xorshift_2_15_25.exe xorshift_5_7_22.exe xorshift_5_17_13.exe xorshift_9_5_1.exe

| ← back | ↑top |
| home |