This is a multi-part message in MIME format.

------=_NextPart_000_0184_01C031EF.A36A4790
Content-Type: text/plain;
        charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

seedy random numbers
Try

<cfset x=randomize(someinteger)>

<cfset y=randrange(1,100)>

<cfoutput>#y#</cfoutput>

The result of the randomize() function is not random as stated in the
Language Reference.  I generally use a timestamp as the seed value.

DC

  -----Original Message-----
  From: Gavin Myers [mailto:[EMAIL PROTECTED]]
  Sent: Friday, October 06, 2000 21:35
  To: CF-Talk
  Subject: seedy random numbers


  okay, i've looked into randomize()
  and from b.f.'s book it states:



  Randomize(Number) seed the random number generator with the passed number

  so if I do this:

  <cfoutput>
  #Randomize(1)#<br>
  <cfset x = randrange(1,100)>
  #x#
  </cfoutput>

  I get:

  0.31415822
  41



  If I put #randomize(2)# instead of 1 i get:

  0.62831643
  50



  with that being said, i could randomze off the timer... but as far as i
can
  see the timer runs only in seconds... wich would be bad.

  So this boils down to:

  Question 1 Is it important to seed the randomizer before using random
  commands? Or does cf automatically do this. The odd part is if it does do
  this automatically then why would we need a seed in the first place?

  Question 2 If it doesnt how can i seed the random number generator? If cf
  doesnt auto-seed the random number generator then I cant do this:

  <cfset x = randrange(1,100)>
  #x#
  </cfoutput>

  #randomize(x)#

  because the randrange wouldn't be seedy and random. Wich brings me over to
  question 3

  How can i use randomize(x) in a fasion that would make it not show up?
  Because in order to use it in the way stated above i have to turn it into
a
  variable...

  do i do this:

  #randomize(124, randrange(x))#

  or would it be more like

  #randomize(124, x)#



  i don't understand why we still have to seed the randomizer... I know a
  computer cannot technically whip out random numbers, but the moment you
ask
  like yyyy:dd:mm:hh:mm:ssssssssssssssssssssssssssssssssssssssss
  should get a pretty random number... unles again if you have a site that
  gets tons of hits per day, there could be a chance of 2 people calling the
  same thing the same second (or even mili-second) and that may depend on
how
  cold fusion server side works.

  feh

  gavin
  --------------------------------------------------------------------------
----
  Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
  To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or
send a message to [EMAIL PROTECTED] with 'unsubscribe' in
the body.


------=_NextPart_000_0184_01C031EF.A36A4790
Content-Type: text/html;
        charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>seedy random numbers</TITLE>
<META content=3D"text/html; charset=3Diso-8859-1" =
http-equiv=3DContent-Type>
<META content=3D"MSHTML 5.00.3018.900" name=3DGENERATOR></HEAD>
<BODY>
<DIV>&nbsp;</DIV>
<DIV><FONT color=3D#0000ff face=3DArial size=3D2><SPAN=20
class=3D338294912-09102000>Try</SPAN></FONT></DIV>
<DIV><FONT color=3D#0000ff face=3DArial size=3D2><SPAN=20
class=3D338294912-09102000></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#0000ff face=3DArial size=3D2><SPAN=20
class=3D338294912-09102000>&lt;cfset=20
x=3Drandomize(someinteger)&gt;</SPAN></FONT></DIV>
<DIV><FONT color=3D#0000ff face=3DArial size=3D2><SPAN=20
class=3D338294912-09102000></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#0000ff face=3DArial size=3D2><SPAN=20
class=3D338294912-09102000>&lt;cfset =
y=3Drandrange(1,100)&gt;</SPAN></FONT></DIV>
<DIV><FONT color=3D#0000ff face=3DArial size=3D2><SPAN=20
class=3D338294912-09102000></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#0000ff face=3DArial size=3D2><SPAN=20
class=3D338294912-09102000>&lt;cfoutput&gt;#y#&lt;/cfoutput&gt;</SPAN></F=
ONT></DIV>
<DIV><FONT color=3D#0000ff face=3DArial size=3D2><SPAN=20
class=3D338294912-09102000></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#0000ff face=3DArial size=3D2><SPAN =
class=3D338294912-09102000>The=20
result of the randomize() function is not random as stated in the =
Language=20
Reference.&nbsp; I generally use a timestamp as the seed=20
value.&nbsp;</SPAN></FONT></DIV>
<DIV><FONT color=3D#0000ff face=3DArial size=3D2><SPAN=20
class=3D338294912-09102000></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#0000ff face=3DArial size=3D2><SPAN=20
class=3D338294912-09102000>DC</SPAN></FONT></DIV>
<DIV><FONT color=3D#0000ff face=3DArial size=3D2><SPAN=20
class=3D338294912-09102000></SPAN></FONT>&nbsp;</DIV>
<BLOCKQUOTE style=3D"MARGIN-RIGHT: 0px">
  <DIV align=3Dleft class=3DOutlookMessageHeader dir=3Dltr><FONT =
face=3DTahoma=20
  size=3D2>-----Original Message-----<BR><B>From:</B> Gavin Myers=20
  [mailto:[EMAIL PROTECTED]]<BR><B>Sent:</B> Friday, October =
06, 2000=20
  21:35<BR><B>To:</B> CF-Talk<BR><B>Subject:</B> seedy random=20
  numbers<BR><BR></DIV></FONT>
  <P><FONT size=3D2>okay, i've looked into randomize()</FONT> <BR><FONT =
size=3D2>and=20
  from b.f.'s book it states:</FONT> </P><BR>
  <P><FONT size=3D2>Randomize(Number) seed the random number generator =
with the=20
  passed number</FONT> </P>
  <P><FONT size=3D2>so if I do this:</FONT> </P>
  <P><FONT size=3D2>&lt;cfoutput&gt;</FONT> <BR><FONT=20
  size=3D2>#Randomize(1)#&lt;br&gt;</FONT> <BR><FONT size=3D2>&lt;cfset =
x =3D=20
  randrange(1,100)&gt;</FONT> <BR><FONT size=3D2>#x#</FONT> <BR><FONT=20
  size=3D2>&lt;/cfoutput&gt;</FONT> </P>
  <P><FONT size=3D2>I get:</FONT> </P>
  <P><FONT size=3D2>0.31415822</FONT> <BR><FONT size=3D2>41</FONT> =
</P><BR>
  <P><FONT size=3D2>If I put #randomize(2)# instead of 1 i get:</FONT> =
</P>
  <P><FONT size=3D2>0.62831643</FONT> <BR><FONT size=3D2>50 =
</FONT></P><BR>
  <P><FONT size=3D2>with that being said, i could randomze off the =
timer... but as=20
  far as i can</FONT> <BR><FONT size=3D2>see the timer runs only in =
seconds...=20
  wich would be bad.</FONT> </P>
  <P><FONT size=3D2>So this boils down to:</FONT> </P>
  <P><FONT size=3D2>Question 1 Is it important to seed the randomizer =
before using=20
  random</FONT> <BR><FONT size=3D2>commands? Or does cf automatically do =
this. The=20
  odd part is if it does do</FONT> <BR><FONT size=3D2>this automatically =
then why=20
  would we need a seed in the first place?</FONT> </P>
  <P><FONT size=3D2>Question 2 If it doesnt how can i seed the random =
number=20
  generator? If cf</FONT> <BR><FONT size=3D2>doesnt auto-seed the random =
number=20
  generator then I cant do this:</FONT> </P>
  <P><FONT size=3D2>&lt;cfset x =3D randrange(1,100)&gt;</FONT> =
<BR><FONT=20
  size=3D2>#x#</FONT> <BR><FONT size=3D2>&lt;/cfoutput&gt;</FONT> </P>
  <P><FONT size=3D2>#randomize(x)#</FONT> </P>
  <P><FONT size=3D2>because the randrange wouldn't be seedy and random. =
Wich=20
  brings me over to</FONT> <BR><FONT size=3D2>question 3</FONT> </P>
  <P><FONT size=3D2>How can i use randomize(x) in a fasion that would =
make it not=20
  show up?</FONT> <BR><FONT size=3D2>Because in order to use it in the =
way stated=20
  above i have to turn it into a</FONT> <BR><FONT =
size=3D2>variable...</FONT> </P>
  <P><FONT size=3D2>do i do this:</FONT> </P>
  <P><FONT size=3D2>#randomize(124, randrange(x))#</FONT> </P>
  <P><FONT size=3D2>or would it be more like</FONT> </P>
  <P><FONT size=3D2>#randomize(124, x)#</FONT> </P><BR>
  <P><FONT size=3D2>i don't understand why we still have to seed the =
randomizer...=20
  I know a</FONT> <BR><FONT size=3D2>computer cannot technically whip =
out random=20
  numbers, but the moment you ask</FONT> <BR><FONT size=3D2>like=20
  yyyy:dd:mm:hh:mm:ssssssssssssssssssssssssssssssssssssssss</FONT> =
<BR><FONT=20
  size=3D2>should get a pretty random number... unles again if you have =
a site=20
  that</FONT> <BR><FONT size=3D2>gets tons of hits per day, there could =
be a=20
  chance of 2 people calling the</FONT> <BR><FONT size=3D2>same thing =
the same=20
  second (or even mili-second) and that may depend on how</FONT> =
<BR><FONT=20
  size=3D2>cold fusion server side works.</FONT> </P>
  <P><FONT size=3D2>feh</FONT> </P>
  <P><FONT size=3D2>gavin</FONT> <BR><FONT=20
  =
size=3D2>----------------------------------------------------------------=
--------------</FONT>=20
  <BR><FONT size=3D2>Archives: <A=20
  href=3D"http://www.mail-archive.com/cf-talk@houseoffusion.com/"=20
  =
target=3D_blank>http://www.mail-archive.com/cf-talk@houseoffusion.com/</A=
></FONT>=20
  <BR><FONT size=3D2>To Unsubscribe visit <A=20
  =
href=3D"http://www.houseoffusion.com/index.cfm?sidebar=3Dlists&amp;body=3D=
lists/cf_talk"=20
  =
target=3D_blank>http://www.houseoffusion.com/index.cfm?sidebar=3Dlists&am=
p;body=3Dlists/cf_talk</A>=20
  or send a message to [EMAIL PROTECTED] with =
'unsubscribe' in=20
  the body.</FONT></P></BLOCKQUOTE></BODY></HTML>

------=_NextPart_000_0184_01C031EF.A36A4790--

------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
To Unsubscribe visit 
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a 
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.

Reply via email to