I'm trying to detect the overflow when adding a signed offset to an unsigned position

```
uint32 position;
int32 offset;  // it could be negative
uint32 position = position+offset;

```

How can I check whether the result is overflow or underflow?

I have thought of an ugly way but not sure of its correctness.

* underflow: `offset < 0 && position + offset >= position`
* overflow: `offset > 0 && position + offset <= position`

And I'm also wondering if there's a more elegant way to do it.

Update:

What's the best solution if offset is long?

```
uint32 position;
long offset;  // it could be negative
uint32 position = position+offset;

```