Operator `==' cannot be applied to operands

hey! iam trying to determinate a quadrant using this tiny Utilitie script:

``````public static Quadrant GetQuadrant(Vector2 v)
{
v = v.normalized;
float angle = Utilities.Normalize360(Mathf.Atan2(v.y, v.x) * 57.29578f);
}

{
angle = Utilities.Normalize360(angle);
if (angle <= 90f)
{
}
else if (angle <= 180f)
{
}
else if (angle <= 270f)
{
}
else if (angle <= 360f)
{
}
else
{
}
return result;
}
``````

and calling it like this:

``````get
{
}
private set
{
``````

but this result in the following error:
Operator `==' cannot be applied to operands of type `Quadrant’ and `int’

any idea why?
thanks!

Pretty much exactly as the error says - GetQuadrant returns a “Quadrant”, but you’re trying to compare it to an integer. I guess you meant to test it like this instead:

``````return quadrant == Quadrant.I || quadrant == Quadrant.II;
``````

I presume Quadrant is an enum? You are trying to compare an enum value with an integer value

``````return quadrant == 1 || quadrant == 2;
``````

There’s no implicit conversion from enum to an integer so the compiler can’t understand how to perform the comparison: it can’t know which integer Quadrant.III for example would equal.

You should probably use the enum’s values to do the comparisons

``````return quadrant == Quadrant.I || quadrant == Qudrant.II;
``````

Or if you have some actual reason to stick to ints, you can do the enum to int casting explicitly

``````return (int)quadrant == 1 || (int)quadrant == 2;
``````

If you do the latter, it might be best to then also explicitly define the integer values of the enum so you can be certain the values are wht you think they are.

``````enum Quadrant {
I = 1,
II = 2,
...
}
``````