
'-------------
'RANDOM
'=============

  '
  'RETURNS RANDOM NUMBER BETWEEN -1 AND 1
  '
  Long seed=0x12345678

/*
  '-----------------------
  Function Rnd() as Single
  '=======================
  '
  Static As Single f, d=1/0x7fffffff
  mov eax,seed
  rol eax,7
  imul eax,eax,13
  mov seed,eax
  push eax
  fild dWord [esp]
  add esp,4
  fmul dWord d
  fstp dWord f
  Function=f
  End Function
*/

  function rnd() as single
  static single d=1/0x7fffffff
  seed=(seed<<<7)*13
  return d*seed       '-1.0 to 1.0
  'return abs(d*seed) ' 0.0 to 1.0
  end function


  '
  string cr=chr(13)+chr(10)
  string pr= "PSEUDORANDOM NUMBERS:" cr
  int i
  for i=1 to 50
    pr+= rnd() cr
  next

  print pr
  
 
