i_to_c

Author: Smashed Transistors
License: LGPL
Github: tiar/conv/i_to_c.axo

Inlets

int32.bipolar i

Outlets

charptr32 o

Attributes

table prefix

Declaration
char c[7 + strlen("attr_prefix")];
char *p = c + strlen("attr_prefix");
Init
strcpy(&c[0], "attr_prefix");
Control Rate
int v = inlet_i;
if (v > 0)
  p[0] = '+';
else if (v < 0) {
  p[0] = '-';
  v = -v;
} else
  p[0] = ' ';
if (v >= 100000) {
  p[1] = 127;
  p[2] = 127;
  p[3] = 0;
} else {
  {
    int d = v / 10000;
    if (d == 0)
      p[1] = ' ';
    else
      p[1] = '0' + d;
    v -= d * 10000;
  }
  {
    int d = v / 1000;
    if (d == 0 && p[1] == ' ')
      p[2] = ' ';
    else
      p[2] = '0' + d;
    v -= d * 1000;
  }
  {
    int d = v / 100;
    if (d == 0 && p[2] == ' ')
      p[3] = ' ';
    else
      p[3] = '0' + d;
    v -= d * 100;
  }
  {
    int d = v / 10;
    if (d == 0 && p[3] == ' ')
      p[4] = ' ';
    else
      p[4] = '0' + d;
    v -= d * 10;
  }
  { p[5] = '0' + v; }

  p[6] = 0;
}

outlet_o = c;

Privacy

© 2024 Zrna Research