Auios

Untitled

Oct 20th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. randomize(timer())
  2.  
  3. function getRandom(min as integer, max as integer) as single
  4.     return (max - min) * rnd() + min
  5. end function
  6.  
  7. function getRandomInt(min as integer, max as integer) as integer
  8.     return (max - min) * rnd() + min
  9. end function
  10.  
  11. dim as integer totalTests = 10000
  12. dim as single highest, lowest = 999999
  13. dim as integer lz, z, gz
  14.  
  15. for i as integer = 0 to totalTests
  16.     dim as single current = getRandom(-1, 1)
  17.     if(current < lowest) then lowest = current
  18.     if(current > highest) then highest = current
  19. next i
  20.  
  21. for i as integer = 0 to totalTests
  22.     dim as single current = getRandomInt(-1, 1)
  23.     if(current < 0) then lz+=1
  24.     if(current = 0) then z+=1
  25.     if(current > 0) then gz+=1
  26. next i
  27.  
  28. print("=== Results ===")
  29. print("Highest: " & highest)
  30. print("Lowest:  " & lowest)
  31. print("lz:      " & lz & " - " & (lz/totalTests)*100 & "%") ' Less than zero
  32. print("z:       " & z & " - " & (z/totalTests)*100 & "%") ' Zero
  33. print("gz:      " & gz & " - " & (gz/totalTests)*100 & "%") ' Greater than zero
  34.  
  35. sleep()
Add Comment
Please, Sign In to add comment