Quote:
Originally Posted by Lateralus
If he's going to do that, he's going to have to cast the (implicitly casted) int to a ushort before setting the value, which means that the value will never be < 0 and he'd have the same problem he has now. I'd also suggest using Math.Max... It looks cleaner, is probably inlined, and does the exact same thing.
|
Yes I realize both of those points. Sorry for not correcting it at the time, was a bit sleepy xD.
@OP: To simplify what they are saying.... Most math (unless specifically told otherwise) will return an integer value. Because of that you will often get issues such as what you're facing where it's saying take int X away from ushort Y. Because ushort can never be negative it loops back to max value. The solution I posted was silly of me because well.. it's wrong :P I'm checking for a negative value after it's already been looped back to max.
Also, Math library functions are lovely and should be used when applicable (no clue why I didn't use them at the time but w/e, gonna blame being super tired)