c# code for simple calculation -


could me c# code. want calculate new a value- value calculated in way: a=a-2*b, see if result less zero , if in range (0,a). doing in few steps, have found code on internet looks better mine, , explanation of problem code solves mine, not sure if code written in proper way or not, because doesn't give me correct result. also, there no reported error in code.

 = - 2 * b < 0 ? 0 : a; 

is code ok thing need, or not?

your code this:

int a;  if((a - 2 * b) < 0) {     = 0; } else {     = a; } 

which doesn't make sense, because set a = a. think want this:

a = (a - 2 * b) < 0 ? 0 : (a - 2 * b); 

Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -