bah! it isnt letting me use the % for modulus division with doubles, is there a way around this? i need to return random doubles, here is how im doing it right now...
double randdouble(double minnum,double maxnum)
{
setprecision(4);
double randomdouble;
if(minnum>maxnum)
{
double temp=minnum;
minnum=maxnum;
maxnum=temp;
}
if(minnum<0&&maxnum<0)
{
minnum*=-1;
maxnum*=-1;
randomdouble=rand()%(maxnum+1);
randomint*=-1;
}
else
{
if(minnum<0)
{
int negative=rand()%2;
if(negative==1)
randomint=rand(maxnum+1);
else
{
maxnum=minnum*-1
randomint=rand(maxnum+1);
randomint*=-1;
}
}
else
{
randomdouble=rand()%(maxnum+1)
while(randomdouble<minnum)
randomdouble=rand()%(maxnum+1)
}
}
return randomdouble;
}
i know there are ways for it to be screwed up, ill fix all the loopholes later, but for now this is my main concern... anyone know anything about doubles ant modulus division? (and id really really rather not use (int) to make it an integer type for that operation...)
double randdouble(double minnum,double maxnum)
{
setprecision(4);
double randomdouble;
if(minnum>maxnum)
{
double temp=minnum;
minnum=maxnum;
maxnum=temp;
}
if(minnum<0&&maxnum<0)
{
minnum*=-1;
maxnum*=-1;
randomdouble=rand()%(maxnum+1);
randomint*=-1;
}
else
{
if(minnum<0)
{
int negative=rand()%2;
if(negative==1)
randomint=rand(maxnum+1);
else
{
maxnum=minnum*-1
randomint=rand(maxnum+1);
randomint*=-1;
}
}
else
{
randomdouble=rand()%(maxnum+1)
while(randomdouble<minnum)
randomdouble=rand()%(maxnum+1)
}
}
return randomdouble;
}
i know there are ways for it to be screwed up, ill fix all the loopholes later, but for now this is my main concern... anyone know anything about doubles ant modulus division? (and id really really rather not use (int) to make it an integer type for that operation...)