dimanche 26 juillet 2020

Cannot convert a very large number to hex

I have the following string: std::string data{"4a00f000f00e1887a9900fff0000004ec00ff004a00f000f00e1887a9900fff0000004ec00ff004a00f000f00e1887a9900fff0000004ec00ff004a00f000f00e1887a9900fff0000004ec00ff000ff004a00f000f00e1887a9900fff000"}

I need to extract it as its equivalent hex value: 4a00f000f00e1887a9900fff0000004ec00ff004a00f000f00e1887a9900fff0000004ec00ff004a00f000f00e1887a9900fff0000004ec00ff004a00f000f00e1887a9900fff0000004ec00ff000ff004a00f000f00e1887a9900fff000

when i do the following code it prints ffffffffffffffff. I see the issue is the value is too large to fix in value but how do I overcome this? Is there a way to perhaps put it in a vector bit by bit using a for loop?

{
    std::istringstream hex_buffer(data);

    unsigned long long value;

    hex_buffer >> std::hex >> value;

    std::cout << value;
    return 0;
}

Aucun commentaire:

Enregistrer un commentaire