- Home /

# 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);
return Utilities.GetQuadrant(angle);
}
public static Quadrant GetQuadrant(float angle)
{
Quadrant result = Quadrant.None;
angle = Utilities.Normalize360(angle);
if (angle <= 90f)
{
result = Quadrant.I;
}
else if (angle <= 180f)
{
result = Quadrant.II;
}
else if (angle <= 270f)
{
result = Quadrant.III;
}
else if (angle <= 360f)
{
result = Quadrant.IV;
}
else
{
UnityEngine.Debug.LogWarning("Undefined Quadrant!");
}
return result;
}
```

and calling it like this:

```
get
{
Quadrant quadrant = Utilities.GetQuadrant(Utilities.Angle360(this.VelocityProjection, this.ForwardProjection));
return quadrant == 1 || quadrant == 2;
}
private set
{
```

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

any idea why? thanks!

**Answer** by tanoshimi
·
Jul 05, 2017 at 09:53 AM

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;
```

**Answer** by NoseKills
·
Jul 05, 2017 at 09:58 AM

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,
...
}
```

### Your answer

### Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.

### Follow this Question

### Related Questions

Apply force at an angle or transform.rotation 1 Answer

Need a little help with quick angle equation 2 Answers

Calculate vector3 from angle 2 Answers

Rotating A Character 180 Degress 1 Answer

Calculating a Second Set of Normals 0 Answers