Hot answers tagged

2

Assuming little-endian bools (least significant bool first), you should use simple bit-shifting, not floating point power calculations: for(int id=start_index;id<=stop_index;id++){ result |= b_array[id] ? (1 << run) : 0; run++; } The ternary operation (b_array[id] ? (1 << run) : 0) means: If b_array[id] is true, then Or result ...


Only top voted, non community-wiki answers of a minimum length are eligible