! * @brief convert a byte to a uppercase hex representation * @param[in] byte byte to represent * @return representation ("00".."FF") */
| 18683 | * @return representation ("00".."FF") |
| 18684 | */ |
| 18685 | static std::string hex_bytes(std::uint8_t byte) |
| 18686 | { |
| 18687 | std::string result = "FF"; |
| 18688 | constexpr const char* nibble_to_hex = "0123456789ABCDEF"; |
| 18689 | result[0] = nibble_to_hex[byte / 16]; |
| 18690 | result[1] = nibble_to_hex[byte % 16]; |
| 18691 | return result; |
| 18692 | } |
| 18693 | |
| 18694 | // templates to avoid warnings about useless casts |
| 18695 | template <typename NumberType, enable_if_t<std::is_signed<NumberType>::value, int> = 0> |