One guess for a start is that MSSB is reading from the wrong side, but do not convert to a string and use find_first_of, why not just use std::bitset's in-built functions?