Basically, I took the method described here, and turned it into a library which can be found here. Obviously the original idea was not mine.
For those who don't want to read the external links, basically..
This library lets you create a new /restricted datum, give it a minimum, maximum, and a current, and then you use the procs provided to change the number, or get information about the number. If you try to change the number out of it's bounds, it will stop at that bound (setting it greater than max will put it at max).
This has some pretty nice benefits for inheritance too. If you make a hp stat, for example, and you have some bars on-screen, you can just override set_current() to change the bar too. An example of what I mean can be seen here.
Overall, I'd say it's pretty neat.