Random numbers in a given range from x to y?

I was wondering if you can generate a random number with IPP that must lie between two given values. So far I managed to do this by rolling certain amounts of dice and adding, substracting or multiplying the result. This only works for certain smaller ranges and depending on the dice you can not get specific min or max values and any possible result in between. For example roll a random number between 5 and 800.

Any ideas? I just don't want to type in tables that generate my random numbers.

Any chance to do this even for a range like from 0.8 to 1.04?

No math.random() I guess...?


  • I found a solution to my specific problem using exotic dice rolls.

    To generate random surface tempreatures for stars in their specific spectral class I now roll a single large die to get the maximum result and add this to a value-1 representing the required minimum result. For example, temperature of M-class main sequence stars ranges in between 2,400–3,700 K. Therefore I roll {2399+1d1300}. 3700-2400=1d1300 for max result, add 3700-1 as min result.

    Same way I solve the issue when rolling solar mass. G-type main-sequence stars range from 0.8 to 1.04 solar masses. I multiply both values by 100 (making this 80 and 1040) and substract 80 from 1040, giving me my die (1d960). Then I add the base value-1 and divide the result by 100 again (1d90+79)/100 giving me a result range of 0.8 to 1.04.

    I still have to find a value so exotic it can't be rolled up by this method.

    This works fine up to {1d1000000000}, larger dice result in an error message '10000000000' is not a valid integer value.
  • Yes, that's probably the simplest way to generate the random range.
  • Ed_NBOS wrote:
    Yes, that's probably the simplest way to generate the random range.
    Great software, can't state this often enough.

    One more thing I noticed:

    It seems I can use potentials in expressions although I can't find anything regarding the use of potentials in the help file.

    This works for me: {10^2} or any other integer potential. Unfortunately {10^3.5} is not possible as IPP only accepts integers in expressions. Same is true for {3.5*10}. The workaroud for this is avoiding decimals like using {10^(35/10)} or {(35/10)*10}.

Leave a Comment