New 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 ...


Top 50 recent answers are included