Prev = 10, Cur = 17, Step = 2.
Is there a method that will give me Prev + Step (or Prev - Step in case Prev > Cur)?
UPD: I’m looking for something like this:
int StepDifference(int A, int B, int N)
{
int ret;
if (A > B)
if (A - N >= B)
ret = A - N;
else
ret = B;
else
if (A + N <= B)
ret = A + N;
else
ret = B;
return ret;
}
Is there an “official” method in Math or other namespaces? I’m going to do this a lot and It could be slower with a custom implementation, I think. Almost every custom implementation of an “official” helper method I tried is slower, that’s why I’m asking.
There is no such method in any Microsoft namespace.