mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 15:59:49 +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 "SharedUtil.h"
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
#include <bitset>
|
||||||
|
|
||||||
double usecTimestamp(timeval *time) {
|
double usecTimestamp(timeval *time) {
|
||||||
return (time->tv_sec * 1000000.0 + time->tv_usec);
|
return (time->tv_sec * 1000000.0 + time->tv_usec);
|
||||||
|
@ -19,7 +20,14 @@ double usecTimestampNow() {
|
||||||
return (now.tv_sec * 1000000.0 + now.tv_usec);
|
return (now.tv_sec * 1000000.0 + now.tv_usec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
float randFloat () {
|
float randFloat () {
|
||||||
return (rand()%10000)/10000.f;
|
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 usecTimestamp(timeval *time);
|
||||||
double usecTimestampNow();
|
double usecTimestampNow();
|
||||||
float randFloat();
|
float randFloat();
|
||||||
|
void outputBits(char);
|
||||||
|
|
||||||
#endif /* defined(__hifi__SharedUtil__) */
|
#endif /* defined(__hifi__SharedUtil__) */
|
||||||
|
|
Loading…
Reference in a new issue