not exact result in computation

i made a program computing the value of a short diagonal and the base of a parallelogram, given the height, base, and side.i compared the result with the calculator which turned out not the same, what should i do with these codes??

double para::shortd(double base, double side, double height,double b1,double b2,double d1)
{
b1=(sqrt((side*side)-(height*height)));
b2=base-b1;
d1=(sqrt((height*height)+(b2*b2)));
gotoxy(15,28);cout<<"The SHORT DIAGONAL is:"<<d1;
return d1=(sqrt((height*height)+(b2*b2)));
}


double para:: LU_BASE (double height, double side, double d1,double b1, double b2, double base)
{
b1=(sqrt((side*side)-(height*height)));
b2=(sqrt((d1*d1)+(height*height)));
base=b2+b1-b1;
gotoxy(15,28);cout<<"The BASE IS:"<<base;
return base=b1+b2;
}
Chances are that your calculator is less precise than your computer. (Floating point values are not perfectly precise.)

BTW, you don't need to calculate things twice.
return d1;

Hope this helps.
Topic archived. No new replies allowed.