Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Fork of Laurus_acc_gyro by
toString.cpp
- Committer:
- ojan
- Date:
- 2015-04-13
- Revision:
- 0:5e220b09d315
File content as of revision 0:5e220b09d315:
#include "toString.h"
void ToBinaryString(char* dest, int destSize, const int integer, int byteNum) {
memset(dest, 0, destSize*sizeof(char));
strcat(dest, "0b");
if(byteNum > 4) {
strcat(dest, "########");
return;
}
for(int i=1; i<=8*byteNum; i++) {
if(integer & (1<<(8*byteNum-i))) {
strcat(dest, "1");
} else {
strcat(dest, "0");
}
}
}
