-1

I have a bitmask of 200 bit stored as a hexadecimal value. In order to apply the & bit operator, I have to first convert the hex to an integer but 200 bit is too big for a uint64 so my question is : how do I split my bitmask in 4 different hexadecimal value without loosing data?

So that I can also split my 200 bit data and then compare every chunk of data with the corresponding chunk of bitmask without altering the result.

ESD
  • 675
  • 2
  • 12
  • 35

2 Answers2

1

You can use the BigInteger from System.Numerics (it's a separate assembly):

BigInteger bi = BigInteger.Parse("01ABC000000000000000000000000000000000", System.Globalization.NumberStyles.HexNumber);

VERY IMPORTANT: prepend a "0" before the hex number! (because BigInteger.Parse("F", NumberStyles.HexNumber) == -1, while BigInteger.Parse("0F", NumberStyles.HexNumber) == 15

BigInteger implement the "classical" logical operators (&, |, ^)

Requires .NET 4.0

xanatos
  • 109,618
  • 12
  • 197
  • 280
0

The most efficient way of achieving this is writing a class that can store and do binary operations on 200bits of data, have strings as input, etc.

sithereal
  • 1,656
  • 9
  • 16