Best way to read a Uint24 and Uint10 from a memoryblock

Am getting a 8-Byte chunk of data from the OS, which contains a Uint24 and a series of Uint10.

I have a somewhat poor solution at the moment which works, but I can’t help feeling like there has to be a better solution.

What would y’all recommend?

const kShift10 as UInt64 = 2^10
const kMask10 as UInt64 = &b1111111111

var source as UInt64 = mb.UInt64Value( 0 )

var part10( 3 ) as UInteger

for i as integer = 3 downto 0  
  part10( i ) = source and kMask10
  source = source \ kShift10

var firstPart as UInteger = source


1 Like

Thanks Kem… There’s a lot to digest here

Before grabbing the UInt64Value from the MemoryBlock, set LittleEndian = False.


This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.