Possible Duplicate:
C++ | Generating a truly random number between 10-20
How to generate random number within range (-x,x)
So I am using a MT to generate my pseudo random numbers, I want to be able to modify these numbers into a value in a range of numbers.
These are the functions I have right now, the first two are int's and the second two are float's, but they do not seem to work right.
static inline int randomi(int min, int max)
{
return Random() % (max-min)+min;
}
static inline unsigned long randomi(int max)
{
return Random() % max;
}
static inline float randomf(float min, float max)
{
return (Random() / ULONG_MAX) * (max-min)+min;
}
static inline float randomf(float max)
{
return (Random() / ULONG_MAX) * max;
}
How can I make these work so they can return ranges that are can be anywhere between including negative ranges or ranges that are on either side of the 0;