! * @brief convert a byte to a uppercase hex representation * @param[in] byte byte to represent * @return representation ("00".."FF") */
| 18597 | * @return representation ("00".."FF") |
| 18598 | */ |
| 18599 | static std::string hex_bytes(std::uint8_t byte) |
| 18600 | { |
| 18601 | std::string result = "FF"; |
| 18602 | constexpr const char* nibble_to_hex = "0123456789ABCDEF"; |
| 18603 | result[0] = nibble_to_hex[byte / 16]; |
| 18604 | result[1] = nibble_to_hex[byte % 16]; |
| 18605 | return result; |
| 18606 | } |
| 18607 | |
| 18608 | // templates to avoid warnings about useless casts |
| 18609 | template <typename NumberType, enable_if_t<std::is_signed<NumberType>::value, int> = 0> |