I want the value of dmg in this equation to be equal or greater than 0. Meaning, if the result is >0 then it gives the result only. But, if the result is <0 i.e. negative it will give 0. I know I can use 'if-else' but want to know if it can be done in one line without 'if-else'.
dmg=int((a-(b/6))*mp);
Edit: I found the answer. I forgot about (x>y)?x:y
dmg= int((a-(b/6))*mp) * (int)(a>b/6); //can't jump. max hides a branch, ?: is a branch. Branch prediction is imperfect, so when its simple like this, avoidance is my preference. max is the pretty way to do it.
** technically it would be a>= but when its equal its still zero. either way.
** this works because zero. the expression becomes larger for general ranges and max becomes more attractive.