ARH
ARH

Reputation: 1395

Cpp Variable/Structure to store 128-bit data

I need some variable/struct to store 32hex number or 128-bit number in an STL container. Do you have any suggestion for me ?

Upvotes: 1

Views: 983

Answers (1)

Daniel
Daniel

Reputation: 31579

You cannot perform arithmetic on 128 bit data without some big integer library (or non-standard SSE extensions I don't know much about anyway).
If you just need to store it use a std::pair<uint64_t, uint64_t> or a struct:

struct bit128
{
    uint64_t higher, lower;
}

If you need bitwise operations use std::bit_vector.
If you need arithmetic you have to use a big integer library like GMP.

Upvotes: 2

Related Questions