Created
April 8, 2014 11:58
-
-
Save thinca/10114309 to your computer and use it in GitHub Desktop.
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
function! GenerateCanonical() | |
let b = 32 | |
let r = (0x7fffffff + 0.0) - (0x80000000 + 0.0) + 1.0 | |
let log2r = float2nr(log(r) / log(2.0)) | |
let k = max([1, (b + log2r - 1) / log2r]) | |
let sum = 0.0 | |
let tmp = 1.0 | |
while k != 0 | |
let sum += (g:V.Random.rand() - (0x80000000 + 0.0)) * tmp | |
let tmp = tmp * r | |
let k -= 1 | |
endwhile | |
return sum / tmp | |
endfunction |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment