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
Post a Comment