15 lines
368 B
C++
15 lines
368 B
C++
#include "utils.h"
|
|
|
|
std::string printBits(uint32_t value) {
|
|
std::string result;
|
|
for (int i = 31; i >= 0; i--) {
|
|
// ottieni il singolo bit
|
|
result += ((value >> i) & 1) ? '1' : '0';
|
|
// aggiungi uno spazio ogni 8 bit, tranne dopo l'ultimo
|
|
if (i % 8 == 0 && i != 0) {
|
|
result += ' ';
|
|
}
|
|
}
|
|
return result;
|
|
}
|