mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-25 16:55:07 +02:00
add helper method to SharedUtil to print bits in char
This commit is contained in:
parent
763c09f562
commit
2f7767bc9b
2 changed files with 10 additions and 1 deletions
|
@ -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");
|
||||
}
|
|
@ -15,5 +15,6 @@
|
|||
double usecTimestamp(timeval *time);
|
||||
double usecTimestampNow();
|
||||
float randFloat();
|
||||
void outputBits(char);
|
||||
|
||||
#endif /* defined(__hifi__SharedUtil__) */
|
||||
|
|
Loading…
Reference in a new issue