I often need this kind of function, for example, for understand the direction of the touches on iPhone and the only way to solve this problem it's by using logic, like this:

```
int dir,distY;
distY = newY-oldY;
if (distY > 0)
{
dir = 1;
}
else if (distY < 0)
{
dir = -1;
}
```

I would like to know if there is an way to do it in one shoot mybey by using a mathematical method or a fashion old-school way.

Clarification, a similar example of what I'm looking for is:

```
i = ++i % max;
```

instead of:

```
i++;
if ( i > max ) { i = 0; }
```