Search notes:

C++ Standard Library: std::hex

std::hex causes integers to be printed in hexadecimal representation. In order to revert back to hexadecimal representation, std::dec is used.
//
// g++ hex.cpp
//
#include <iostream>
#include <iomanip>


int main() {

    std::cout             << 100   << std::endl;
    std::cout << std::hex << 100   << std::endl;
    std::cout <<             100.1 << std::endl;
    std::cout << std::dec << 100   << std::endl;

}
Github repository about-cpp-standard-library, path: /iomanip/hex.cpp
Output:
100
64
100.1
100

Converting from hexadecimal representation to long

std::hex can also be used to convert a string that contains an integral value in hexadecimal represantion to a long:
#include <iostream>
#include <sstream>
#include <string>

int main() {
   std::stringstream ss;

   std::string value_in_hex("1E240");
   long        value_in_dec;

   ss << std::hex << "1E240";
   ss >> value_in_dec;

   std::cout << "0x" << value_in_hex << " = " << value_in_dec << std::endl;
}
Github repository about-cpp-standard-library, path: /iomanip/hex_convert-hex-to-dec.cpp

See also

C++ Standard Library

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1759390571, '216.73.216.42', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/languages/C-C-plus-plus/CPP-Standard-Library/iomanip/hex(83): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78