Jump to content

Sody

Members
  • Content Count

    2
  • Joined

  • Last visited

Community Reputation

0 Neutral

About Sody

  • Rank
    Newbie
  1. Thanks Heinrich, I agree that no setting of seed is a problem. I will rember to be careful if I need to generate random number with rand().
  2. Hi, I am a new user following the tutorials step by step. I have tried the Case-by-Case Analysis , and I doubted about the values generated by the function rand(). So I slightly changed the code as shown below to show the exact random number. double value_base(rand()*100) integer value(value_base.toUInt()) integer difference(abs(value - try)) echo(" ") echo("Random number is " + value_base) echo("My try is " + try) if (difference == 0) echo("congratulations, you are spot on!") else echo("No, that was not the number.") echo("The number I was thinking of was " + value) endif The feature runs OK. The result is showed in terminal like: I kept testing this feature with input "try" from 1 to 40, and collect the random number generated. They are like: try Random number try Random number try Random number try Random number try Random number 1 80.8741 2 80.8741 3 58.5009 4 80.8741 5 89.5962 6 19.3304 7 56.3585 8 47.9873 9 58.5009 10 19.3304 11 0.125126 12 58.5009 13 35.0291 14 47.9873 15 19.3304 16 19.3304 17 56.3585 18 80.8741 19 0.125126 20 19.3304 21 80.8741 22 47.9873 23 35.0291 24 19.3304 25 58.5009 26 80.8741 27 89.5962 28 56.3585 29 80.8741 30 58.5009 31 58.5009 32 47.9873 33 58.5009 34 80.8741 35 89.5962 36 58.5009 37 47.9873 38 82.284 39 80.8741 40 19.3304 Obviously some values were repeatedly generated, as shown in colors above, and the values were not uniformly distributed. My OS is Windows 11, and my caeses version is 5.3.4 . I am not sure if I used the function rand() properly. Could someone tell me what is wrong here? complete console output.txt
×
×
  • Create New...