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
Diff: toString.cpp
- Revision:
- 0:5e220b09d315
diff -r 000000000000 -r 5e220b09d315 toString.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/toString.cpp Mon Apr 13 08:10:05 2015 +0000
@@ -0,0 +1,17 @@
+#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");
+ }
+ }
+}
\ No newline at end of file
