Skip to content

Instantly share code, notes, and snippets.

@ynkdir
Created January 17, 2011 12:41
Show Gist options
  • Save ynkdir/782807 to your computer and use it in GitHub Desktop.
Save ynkdir/782807 to your computer and use it in GitHub Desktop.
msvcrt rand()
" Visual C++ 2010: rand.c
let s:RAND_MAX = 32767
let s:seed = 0
function! Srand(seed)
let s:seed = a:seed
endfunction
function! Rand()
let s:seed = s:seed * 214013 + 2531011
return (s:seed < 0 ? s:seed - 0x80000000 : s:seed) / 0x10000 % 0x8000
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment