3

Suppose I have a UInt128 like this

UInt64 upperA = 7, lowerA = 8;
UInt128 foo = new(upperA, lowerA);
++foo;

And now I want to extract the two UInt64s from the updated foo.
If they were properties, I could do this

UInt64 upperB = foo.Upper, lowerB = foo.Lower;

But they aren't, so how do I get them?

Theodor Zoulias
  • 34,835
  • 7
  • 69
  • 104
Hal Heinrich
  • 544
  • 1
  • 4
  • 21

1 Answers1

5

By converting to UInt64 you can get the lower bits already; to get the upper one you can apply a bit shift first:

var lower = (UInt64)foo;
var upper = (UInt64)(foo >> 64);
H.B.
  • 166,899
  • 29
  • 327
  • 400