! * @brief convert a byte to a uppercase hex representation * @param[in] byte byte to represent * @return representation ("00".."FF") */
| 18559 | * @return representation ("00".."FF") |
| 18560 | */ |
| 18561 | static std::string hex_bytes(std::uint8_t byte) |
| 18562 | { |
| 18563 | std::string result = "FF"; |
| 18564 | constexpr const char* nibble_to_hex = "0123456789ABCDEF"; |
| 18565 | result[0] = nibble_to_hex[byte / 16]; |
| 18566 | result[1] = nibble_to_hex[byte % 16]; |
| 18567 | return result; |
| 18568 | } |
| 18569 | |
| 18570 | // templates to avoid warnings about useless casts |
| 18571 | template <typename NumberType, enable_if_t<std::is_signed<NumberType>::value, int> = 0> |