Depends on what you want to do. If you want to force a negative result to 0, use
int someval = origval < 0 ? 0 : origval;
If you want the absolute value, then the Math.Abs() function will do that, however if your input value is an int it will be converted to a double.
0 comments:
Post a Comment