All pastes #919750 Raw Edit

Anonymous

public cpp v1 · immutable
#919750 ·published 2008-02-26 23:23 UTC
rendered paste body
    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()