Page 1 of 1
Programming question
Posted: Wed Jul 12, 2017 10:14 pm
by Ice Cream Jonsey
You want something to happen one out of a thousand times.
Would you do this:
foobar = random(10000)
if foobar > 9990
Or this?
foobar = random(1000)
if foobar =1000
Posted: Thu Jul 13, 2017 4:50 am
by Flack
Statistically I think they're the same. I assume the second (1/1000) requires less cycles, but not possibly enough to make a difference in modern systems.
Posted: Thu Jul 13, 2017 5:22 am
by pinback
foobar = random(1000)
if foobar = 69
huhhhuhu
EDIT: In most languages "if foobar = 1000", as you had it, wouldn't work, because in most languages "random(1000)" would return a number from 0 to 999.
Posted: Thu Jul 13, 2017 5:48 am
by Ice Cream Jonsey
pinback wrote:foobar = random(1000)
if foobar = 69
huhhhuhu
EDIT: In most languages "if foobar = 1000", as you had it, wouldn't work, because in most languages "random(1000)" would return a number from 0 to 999.
Thanks. Not in Hugo it doesn't, Hugo is smart enough to interpret that how I wrote it, and that was what I was writing in before HURRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
Posted: Thu Jul 13, 2017 6:55 am
by RealNC
I prefer floating point for this, just so I can write "0.1" to mean 0.1%. Too bad Hugo doesn't have FP.
Wouldn't it fun to do Bitcoin mining in Hugo? :P