Ranged numbers

This is a discussion on Ranged numbers within the Game Programming forums, part of the General Programming Boards category; Hey ! I was bored and I had this idea so here it is. It's a simple class containing a ...

Ranged numbers

Hey ! I was bored and I had this idea so here it is. It's a simple class containing a Data field and a Min and Max field where Data will be a number between Min and Max. Why is this in game programming ? Well, you can use this to contain the health, mana or whatever you wish. I've overloaded most operators though I can't see to make the pre and post-increment operators work. A problem of syntax, perhaps someone can help.

PS: I know it may be a little bit of overhead but I think it cleans up a little of the mess in your code since you don't have to check boundaries and such.

That's real nice, now what happens if that macro is used in a conditional statement, loop statement, or function? Don't design bad code because you know the limited ways it could be used properly. Write good code and then you don't have to worry about whether or not you can use it where you're using it.

I tried to add a little system to catch the difference between a and min or a and max in case of an overflow/underflow but I get a "OverflowException<T> cannot be raised" error (and the same for UnderflowException), what does that mean ?