-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
misc random #429
Comments
see man urandom and man getentropy
etc EDIT: would help properly fix nim-lang#8588 |
|
|
This is really useful. |
when true:
#[
D20201208T123017:here
]#
import std/random
import std/fenv
proc main()=
echo rand(-Inf .. Inf) # bug: nan
echo rand(0.0 .. Inf) # ok: inf
echo rand(0.0 .. float.maximumPositiveValue) # ok: 5.992393389465399e+307
echo rand(-float.maximumPositiveValue .. float.maximumPositiveValue) # bug: inf
echo rand(float.maximumPositiveValue) # ok: 7.976840732228883e+307
echo rand(Inf) # ok: inf
main() |
(either using threadvar or using locks) |
|
|
(suggested by @xflywind) |
|
|
# CSPRNG
var r = initRand(opt = useSysrand)
sampleBuffer(r, buf, alphabet)
# PRNG
var r = initRand(opt = useTime)
sampleBuffer(r, buf, alphabet)
# CSPRNG
randomize() # could be changed to: randState = initRand(opt = useSysrand)
sampleBuffer(randState, buf, alphabet) # uses default RNG |
D20201208T190246
links
The text was updated successfully, but these errors were encountered: