News for hackers. Stuff that matters.
Re:Essential C [pdf] by j-walker on Tuesday March 08, 2022 @02:58AM (#30597574)
Can someone explain to me why in Section 4: Functions they compute Twice by multiplying the number by three then subtracting the number once? Is it just to showcase more math, or is there a detail I'm missing?

> /* Computes double of a number. Works by tripling the number, and then subtracting to get back to double. /

   static int Twice(int num) {

      int result = num * 3;

      result = result - num;

      return(result);**

There are no comments on this comment yet.