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