Math and random chance

Evalis

Prince
Joined
Mar 2, 2009
Messages
505
How would I write code that presents a random number between .9997 and .9557?

To further explain, what I need is a 'roll' that is capable of using non-integer values along with a somewhat complicated math formula. Which of course leads to my second question:

How would I write .01+ 1 - (.998 to the power of x times .999 to the power of y) ?
 
How would I write code that presents a random number between .9997 and .9557?

From the Lua math library reference

Code:
math.random(lower, upper) generates integer numbers between lower and upper

Code:
math.random(9557, 9997) / 1000
 
How would I write .01+ 1 - (.998 to the power of x times .999 to the power of y) ?

Again from the Lua math library reference

Code:
math.pow() raises the first parameter to the power of the second parameter and returns the result.
The binary ^ operator performs the same job as math.pow(), i.e. math.pow(x,y) == x^y.

You should be able to work it out from that
 
Back
Top Bottom