Random again

This WebDNA talk-list message is from

2003


It keeps the original formatting.
numero = 47438
interpreted = N
texte = A while ago there was some discussion about using [math]ceil([RANDOM format=float]*(randomrange))[/math] to get a random number. We were just trying this and came up with an anomaly: including the occasional negative number!!! (and the negative number always is in the range -480 to -490ish.Here's our code. It looks for a RANDOM no up to 99 over 50,000 loops, and counts the number of occurences of 1, numbers in the 90s, 0, and less than zero.[math show=f]one_count=0[/math] [math show=f]ninety_count=0[/math] [math show=f]zero_count=0[/math] [math show=f]minuszero_count=0[/math][loop start=1&end=50000&advance=1] [text show=f]random_number=[math]ceil([RANDOM format=float]*(99))[/math][/text] [!][showif [random_number]<1][index]. [random_number]
[/showif][/!][showif [random_number]=1][math show=f]one_count=[one_count]+1[/math][/showif] [showif [random_number]>90][math show=f]ninety_count=[ninety_count]+1[/math][/showif] [showif [random_number]=0][math show=f]zero_count=[zero_count]+1[/math][/showif] [showif [random_number]<0][math show=f]minuszero_count=[minuszero_count]+1[/math][/showif][/loop]one_count: [one_count]
ninety_count: [ninety_count]
zero_count: [zero_count]
minuszero_count: [minuszero_count] Regards, Tim -- Tim Robinson IDFK Web Developments tim@idfk.com.au 114a/40 Yeo Street Neutral Bay 2089 Australia Phone +612 9908 2134 Fax +612 9908 4837------------------------------------------------------------- This message is sent to you because you are subscribed to the mailing list . To unsubscribe, E-mail to: To switch to the DIGEST mode, E-mail to Web Archive of this list is at: http://webdna.smithmicro.com/ Associated Messages, from the most recent to the oldest:

    
  1. Re: Random again (Rob Marquardt 2003)
  2. Random again (Tim Robinson 2003)
A while ago there was some discussion about using [math]ceil([RANDOM format=float]*(randomrange))[/math] to get a random number. We were just trying this and came up with an anomaly: including the occasional negative number!!! (and the negative number always is in the range -480 to -490ish.Here's our code. It looks for a RANDOM no up to 99 over 50,000 loops, and counts the number of occurences of 1, numbers in the 90s, 0, and less than zero.[math show=f]one_count=0[/math] [math show=f]ninety_count=0[/math] [math show=f]zero_count=0[/math] [math show=f]minuszero_count=0[/math][loop start=1&end=50000&advance=1] [text show=f]random_number=[math]ceil([RANDOM format=float]*(99))[/math][/text] [!][showif [random_number]<1][index]. [random_number]
[/showif][/!][showif [random_number]=1][math show=f]one_count=[one_count]+1[/math][/showif] [showif [random_number]>90][math show=f]ninety_count=[ninety_count]+1[/math][/showif] [showif [random_number]=0][math show=f]zero_count=[zero_count]+1[/math][/showif] [showif [random_number]<0][math show=f]minuszero_count=[minuszero_count]+1[/math][/showif][/loop]one_count: [one_count]
ninety_count: [ninety_count]
zero_count: [zero_count]
minuszero_count: [minuszero_count] Regards, Tim -- Tim Robinson IDFK Web Developments tim@idfk.com.au 114a/40 Yeo Street Neutral Bay 2089 Australia Phone +612 9908 2134 Fax +612 9908 4837------------------------------------------------------------- This message is sent to you because you are subscribed to the mailing list . To unsubscribe, E-mail to: To switch to the DIGEST mode, E-mail to Web Archive of this list is at: http://webdna.smithmicro.com/ Tim Robinson

DOWNLOAD WEBDNA NOW!

Top Articles:

Talk List

The WebDNA community talk-list is the best place to get some help: several hundred extremely proficient programmers with an excellent knowledge of WebDNA and an excellent spirit will deliver all the tips and tricks you can imagine...

Related Readings:

WebCatalog on SUSE-Linux 6.3... please help! (2000) Snake Bites (1997) Return records from another (1997) Error: this shopping cart has already been submittedm (2004) Database changes (1998) Search a date field specificly the month only... (1999) HELP WITH DATES (1997) tricky embedded[showifs/hideifs] (w/ code.. long) (2000) Off Topic: MacOS X Server on iMac (2000) Too many wrong answers! (1998) WebCat2.0 [format thousands .0f] no go (1997) sort problems....bug or brain fart? (1997) Purchase Plugin Missing (1996) Email (1998) How to find duplicates - With code samples (2000) How long until WebDNA makes the list? :( (2004) Who is John Jakovich? (1999) Umm...about those log files? (Off Topic) (1997) help (2001) SELECT Into File (2006)