I forgot to mention I was using format with the default 'f' for the format 
string. If i use .3f as the format string, I still do not get the range I'm 
looking for; more like numbers far in between. Any suggestions?

----- Original Message ----- 
From: "Richard R." <[EMAIL PROTECTED]>
To: "Delphi-Talk Discussion List" <delphi-talk@elists.org>
Sent: Tuesday, October 03, 2006 4:35 AM
Subject: floating point random range


> hello. I am working on some code that uses a random range of floating 
> point
> values. I have come up with this
>
> 0.001 + (RandomRange(0, 32767) / 32767) * (0.5 - 0.001)
>
> but the problem is that it returns values 0.01 - 0.5 instead of 0.001 - 
> 0.5
> Is there a better way to do this? Also Is this forum ok to ask math
> questions? It is delphi related lol
>
> __________________________________________________
> Delphi-Talk mailing list -> Delphi-Talk@elists.org
> http://www.elists.org/mailman/listinfo/delphi-talk
> 

__________________________________________________
Delphi-Talk mailing list -> Delphi-Talk@elists.org
http://www.elists.org/mailman/listinfo/delphi-talk

Reply via email to