How to convert a number to binary ?

unsigned long convToBin(unsigned int x) {'
  unsigned long ret = 0;
  for (unsigned char i=0; i<sizeof(x)*8; i++) {
    if (x & _BV(i)) ret += 10 * i;
  }
}

untested