a math problem . . . i hope atleast
hey all, hope you're having a good weekend. one of my functions isn't returning what i think should be a proper value, so i was hoping to post it, surf around a bit, and then someone will by magic solve all my problems and i don't have to do the work:D will that person be you?
here's the function:
Code:
int Player::mf_playerStats_battingAve(char fv_mgrDirection)
{
//bunt
if (fv_mgrDirection=='b'||'B')
{return ((2*bat_aim)+bat_str+(rand() % lck));}
//left grounder
if (fv_mgrDirection=='l'||'L')
{return ((bat_str)+(.75*bat_aim)+(rand() % lck));}
//right grounder
if (fv_mgrDirection=='r'||'R')
{return ((bat_str)+(.75*bat_aim)+(rand() % lck));}
//sacrafice fly
if (fv_mgrDirection=='s'||'S')
{return ((bat_aim)+(bat_str)+(rand() % lck));}
//homerun********should run this if*************
if (fv_mgrDirection=='h'||'H')
{return ((.5*bat_str)+(bat_aim)+(rand() % lck));}
//default
else
{return ((.5*bat_str)+(bat_aim)+(rand() % lck));}
}
here's the values acording to the debugger:
Quote:
bat_aim 10
bat_str 10
fv_mgrDirection 104 'h'
lck 10
+ this 0x0012ff48
rand returned 29372
so, as i see it the equation should read:
(.5*10)+(10)+(2)==19, right?
well, on this occasion it came up with 32. all the returned values tend to be in the low 30's. so what gives? what am i missing? thanks in advance :)