Search code examples
c++type-conversionintegerhexsize

Define a huge hexadecimal number


I am working with a function cksumcrc32(init, (unsigned char *) &data, len);. The problem is that variable data is quite big, in hexadecimal is: 0x0020b3801005064000007d8000000000000000000000200000000000000000000000000, in terms of bytes, it is 36 bytes long. I am trying to define the variable in c++, but errors like "integer literal is too large to be represented in any integer type" appear. I would appreciate it if someone could help me defining this big variable, I have looked at similar threads but I have not seen help for such big variables. Thanks.


Solution

  • I think what you are looking for is an array of these bytes (or a vector) in the format:

    std::vector<std::byte> arr;
    arr.push_back(byte);
    

    With this, you can individually add bytes of the number into this vector, allowing the integer to be as large as you want.