aboutsummaryrefslogtreecommitdiff
path: root/hex_functions.cpp
blob: 4a58d2b4dfe02f44d3242e63556e59aaca5f3b40 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#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;
  }
}