C++ convert hex string to signed integer

前端 未结 9 1901
耶瑟儿~
耶瑟儿~ 2020-11-22 03:08

I want to convert a hex string to a 32 bit signed integer in C++.

So, for example, I have the hex string \"fffefffe\". The binary representation of this is 111111

9条回答
  •  死守一世寂寞
    2020-11-22 03:18

    just use stoi/stol/stoll for example:

    std::cout << std::stol("fffefffe", nullptr, 16) << std::endl;
    

    output: 4294901758

提交回复
热议问题