Decimal Division function

Hi, I need some help with my Calculator class' function. I have it to add, subtract, multiply, and divide. I need a decimal divisor script! How do I make it divide divis by divid? Example 2/5 = 0.4, not 0. It needs to return the value in
 
return divid/divis      // divis == 5, divid == 2 

and it's rounding! Help!


1
2
3
4
  calculator::divide(int divid,int divis)    // here's the function declaration
  {
    return divid/divis;
  }
1
2
3
4
double calculator::divide( int divid, int divis )
{
   return ( divid + 0.0 ) / divis;
}
Last edited on
@lastchance Thanks for the fast response! Will try!
Registered users can post here. Sign in or register to post.