I must have been dead tired and brain dead. I already found code I wrote on this subject lol. It's funny to ask for code you already wrote lol
function frand(const min, max: single): single; begin Result:= Random * (max - min) + min; end; ----- Original Message ----- From: "Rory Daulton" <[EMAIL PROTECTED]> To: "Delphi-Talk Discussion List" <delphi-talk@elists.org> Sent: Tuesday, October 03, 2006 1:22 PM Subject: Re: floating point random range > Richard, > >> 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-related Math questions are fine here. I love them! > > I don't know what RandomRange is, but this should work to return values > between A and B, including A but not including B: > > A + (B - A) * Random > > Rory Daulton > [EMAIL PROTECTED] > > > __________________________________________________ > 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