Anonymous
public cpp v1 · immutable string & Int2Bin (int Val, string & Result) throw () { const unsigned short CstNbBits = sizeof (Val) * 8; Result.clear(); Result.reserve (CstNbBits + CstNbBits / 4); for (unsigned short i (CstNbBits); i-- > 0; ) { Result.push_back (0 == (Val & 1 << i) ? '0' : '1'); if (0 == (i % 4)) Result.push_back (' '); } Result.erase (Result.end() - 1); return Result; } // Int2Bin()