aboutsummaryrefslogtreecommitdiff
path: root/src/hex_functions.cpp
blob: 1e35718fe1ccbddeaed3efd54482fe4540097167 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include "hex_functions.h"

namespace omni {
std::string int_to_hex(unsigned int input)
{
  if (input > 255)
    return "FF";

  std::stringstream stream;
  stream << std::setfill('0') << std::setw(sizeof(char) * 2) << std::hex
         << input;
  std::string result(stream.str());
  std::transform(result.begin(), result.end(), result.begin(), ::toupper);

  return result;
}
} // namespace omni