Keisuke Sehara
/
STM32_Whisking
fast-feedback virtual target task code on STM Nucleo
Diff: utils.h
- Revision:
- 23:61af0317e404
- Parent:
- 8:973dcd190672
--- a/utils.h Tue Jul 03 10:50:14 2018 +0000 +++ b/utils.h Tue Jul 03 13:46:21 2018 +0000 @@ -1,5 +1,6 @@ #ifndef UTILS_H_ #define UTILS_H_ +#include <string> #include "IO.h" inline bool isWhitespace(const char& ch) { @@ -16,6 +17,23 @@ return ((us_timestamp_t)ms)*1000; } +inline std::string uint64_to_str(uint64_t value, const uint16_t& base=10) +{ + std::string result; + + do { + char c = value % base; + value /= base; + + if (c < 10) + c +='0'; + else + c += 'A' - 10; + result = c + result; + } while (value); + return result; +} + template <typename V> V parseUnsignedFromSerial(const V& defaultvalue) {