f_to_c

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

Inlets

frac32 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
float f = inlet_i * (1.0f / (1 << 21));
if (inlet_i > 0)
  p[0] = '+';
else if (inlet_i < 0) {
  p[0] = '-';
  f = -f;
} else
  p[0] = ' ';
if (f >= 1000) {
  p[1] = 127;
  p[2] = 127;
  p[3] = 0;
} else {
  {
    int cent = (int)(f / 100);
    if (cent == 0)
      p[1] = ' ';
    else
      p[1] = '0' + cent;
    f -= cent * 100;
  }
  {
    int diz = (int)(f / 10);
    if (diz == 0)
      p[2] = ' ';
    else
      p[2] = '0' + diz;
    f -= diz * 10;
  }
  {
    int un = (int)(f);
    p[3] = '0' + un;
    f -= un * 1;
    p[4] = '.';
  }
  {
    int diz = (int)(f * 10);
    p[5] = '0' + diz;
    f -= diz * 10;
  }
  p[6] = 0;
}

outlet_o = c;

Privacy

© 2024 Zrna Research