![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Does anyone know how to generate a random number within a specified range (ex: between 100-200)? I tried Int(Mod(Random * 100, 200)) but that doesn't work. |
#3
| |||
| |||
|
|
(ex: between 100-200) |
#4
| |||
| |||
|
|
"stabit" <sharon.tabit (AT) gmail (DOT) com> schreef in bericht news:1175967314.821249.26480 (AT) e65g2000hsc (DOT) googlegroups.com... Does anyone know how to generate a random number within a specified range (ex: between 100-200)? I tried Int(Mod(Random * 100, 200)) but that doesn't work. Really random doesn't exist within Filemakers world. You might try a calcfield cRandomNum |
)|
You might try a calcfield cRandomNum Let( [ cRandomNum = Int(Random * 100000)];cRandomNum) Which will return a random between -1 and 99999. Snip |
#5
| |||
| |||
|
|
You might try a calcfield cRandomNum Let( [ cRandomNum = Int(Random * 100000)];cRandomNum) Which will return a random between -1 and 99999. Snip Errr... the Random function returns a number between 0 and 1, so that calculation above will return a "random" number between 0 and 100000. |
#6
| |||
| |||
|
|
Does anyone know how to generate a random number within a specified range (ex: between 100-200)? I tried Int(Mod(Random * 100, 200)) but that doesn't work. |
#7
| |||
| |||
|
|
You might try a calcfield cRandomNum Let( [ cRandomNum = Int(Random * 100000)];cRandomNum) Which will return a random between -1 and 99999. Snip Errr... the Random function returns a number between 0 and 1, so that calculation above will return a "random" number between 0 and 100000. I slightly disagree with that. And to try this I have built a file, just one field (the calc above). and a script in a loop I generate one million records (took about 45 minutes). It generated 8 records containing 0. It generated no reords containing 100000. The highest it got was 99999 and had 8 records of this as well. Just to satisfy my curiousity, I looked at some other numbers within the file and noticed thatother amounts also existed. Like 99998 has 28 occurrances. So it looks like we are both partly right. The function will generate a number between -1 and 100000. Keep well, Ursus |
#8
| |||
| |||
|
|
existed. Like 99998 has 28 occurrances. So it looks like we are both partly right. The function will generate a number between -1 and 100000. Keep well, Ursus If you look at your test numbers you will find NONE of them are below zero. |
|
The Random function only returns a "random" number between 0 and 1, so multiplying its result by 100000 will mathematically give you a number between 0 and 100000 ... no negatives are possible with that calculation. I was partly wrong though in the bit you snipped off. |
#9
| |||
| |||
|
|
If you want the possibility of getting the 100000 you need to alter the function to be: Int(Random * 100001) |
#10
| |||
| |||
|
|
existed. Like 99998 has 28 occurrances. So it looks like we are both partly right. The function will generate a number between -1 and 100000. Keep well, Ursus If you look at your test numbers you will find NONE of them are below zero. Yes, that is what I said. Between -1 and 100000, or in other words excluding those values and including 0 and 99999. |
![]() |
| Thread Tools | |
| Display Modes | |
| |