# Compare double with int, cast int on double?

Discussion in 'C++' started by nubore, Oct 6, 2010.

1. ### nuboreNew Member

Joined:
Oct 6, 2010
Messages:
1
0
Trophy Points:
0
Code:
```string CTriangle::TriangleType(string TypeOfTriangle)
{
if ( ValidTriangle() )
{
if ( SideA == SideB && SideA == SideC && SideB == SideC )
{
TypeOfTriangle = "Equilateral Triangle";
}
if ( int(AngleA()) == 90 || int(AngleB()) == 90 || int(AngleC()) == 90 )
{
TypeOfTriangle = "Right-Angled Triangle";
}
if ( SideA == SideB || SideA == SideC || SideB == SideC )
{
TypeOfTriangle = "Isoscules Triangle";
}
if ( (SideA != SideB && SideA != SideC && SideB != SideC) && ( AngleA() < 90.0 && AngleB() < 90.0 && AngleC() < 90.0 ) )
{
TypeOfTriangle = "Scalene/Acute Triangle";
}
/*
if ( AngleA() < 90.0 && AngleB() < 90.0 && AngleC() < 90.0 )
{
TypeOfTriangle = "Acute-Angled Triangle";
}
*/
if ( (AngleA() > 90.0 || AngleB() > 90.0 || AngleC() > 90.0) && (SideA != SideB && SideA != SideC && SideB != SideC) )
{
TypeOfTriangle = "Obtuse/Scalene Triangle";
}
if ( AngleA() > 90.0 || AngleB() > 90.0 || AngleC() > 90.0 )
{
TypeOfTriangle = "Obtuse Triangle";
}
return TypeOfTriangle;
}
else
exit(1);
}```
how do I compare AngleA() with 90? I cast int before AngleA() (its return value is double) but if I put a (3,4,5) triangle, it goes down to
Code:
``` if ( (SideA != SideB && SideA != SideC && SideB != SideC) && ( AngleA() < 90.0 && AngleB() < 90.0 && AngleC() < 90.0 ) )
{
TypeOfTriangle = "Scalene/Acute Triangle";
}```
i have all the values computed and on the command prompt shows AngleC = 90.000, (setprecision(3)), need help please