add helper method to SharedUtil to print bits in char

This commit is contained in:
Stephen Birarda 2013-03-15 12:25:13 -07:00
parent 763c09f562
commit 2f7767bc9b
2 changed files with 10 additions and 1 deletions

View file

@ -8,6 +8,7 @@
#include "SharedUtil.h"
#include <cstdlib>
#include <bitset>
double usecTimestamp(timeval *time) {
return (time->tv_sec * 1000000.0 + time->tv_usec);
@ -19,7 +20,14 @@ double usecTimestampNow() {
return (now.tv_sec * 1000000.0 + now.tv_usec);
}
float randFloat () {
return (rand()%10000)/10000.f;
}
void outputBits(char byte) {
printf("%d: ", byte);
for (int i = 0; i < 8; i++) {
printf("%d", byte >> (7 - i) & 1);
}
printf("\n");
}

View file

@ -15,5 +15,6 @@
double usecTimestamp(timeval *time);
double usecTimestampNow();
float randFloat();
void outputBits(char);
#endif /* defined(__hifi__SharedUtil__) */