gen changing names of parameters, screwing up my formula, causing errors.


    May 02 2014 | 8:00 am
    i type this in to codebox:
    round(num)
    {
    b = abs(num);
    a = ceil(b - 1);
    a = b - a;
    if(a >= .5){
    b = ceil(b);
    }
    else{
    b = floor(b);
    }
    if(num < 0){
    num = -b;
    }
    else{
    num = b;
    }
    return num;
    }
    out1 = round(in1/in2)*in2;
    i get this in "code" tab:
    round(num) {
    b = abs(b);
    a = ceil(b - 1);
    a_1 = b - a;
    if(a_1 >= 0.5) {
    b = ceil(b);
    }
    else {
    b = floor(b);
    }
    if(b < 0) {
    b = -b;
    }
    return b;
    }
    expr_2 = round(in1 / in2) * in2;
    out1 = expr_2;
    notice num is not even passed into the function.
    whyyyyyy? :(
    btw,

    • May 03 2014 | 12:51 am
      it's obviously gen not liking the fact im using the same variable multiple times or something. so there's a formula that gen doesn't mind:
      round(num)
      {
      rounded=0.0;
      pos = abs(num);
      up = ceil(pos);
      down = floor(pos);
      checkup = up - pos;
      checkdown = pos - down;
      if(checkup rounded = up;
      }
      else{
      rounded = down;
      }
      return sign(num)*rounded;
      }
      out1 = round(in1/in2)*in2;
    • May 06 2014 | 8:42 pm
      This is definitely a bug. Thanks for the example. Here's a slight modification to the code that will compiler properly:
      round(num) {
      b = abs(num);
      a = ceil(b - 1);
      a = b-a;
      if(a > 0.5) {
      b = ceil(b);
      }
      else {
      b = floor(b);
      }
      res = 0;
      if(num < 0) {
      res = -b;
      }
      else {
      res = b;
      }
      return res;
      }
    • May 12 2014 | 10:02 pm
      another problem
      x=1;
      y=2;
      x,y=y,x;
      out1 = x;
      out2 = y;
      turns into
      expr_1 = 2;
      expr_2 = 2;
      out2 = expr_2;
      out1 = expr_1;
      notice how both outputs are now equal to 2.