Re: Smallest Non-Zero Number from rnd()

new topic     » goto parent     » topic index » view thread      » older message » newer message
euphoric said...

What is the smallest non-zero number that rnd() will return?

It seems to be 0.01. If so, is there any way to make it more precise?

For example, to get numbers between 0.001 and 1? or 0.0001 and 1?

I guess I could always multiply to get integers and use rand_range()...

Perhaps I'm misunderstanding the question, but a test shows me that rnd() can return numbers smaller than 0.01:

include std/rand.e 
atom x 
while 1 do 
x = rnd()  
if x < 0.001 then ? x end if 
end while 

0.0006218517863 
0.0009995880243 
0.0002405867837 
0.000242709016 
0.0004686160389 
0.0007781575098 
0.0003000935483 

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu