as title #include <sstream> #include <iostream> int main() { unsigned int x; std::stringstream ss; ss << std::hex << "FF"; ss >> x; // output it as a signed type std::cout << static_cast<int>(x) << std::endl; }