Uint24 and Uint10

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?

memoryblock & bit masks ?
how is this laid out ?
that seems really odd formats but …

The official format is

// uint64_t version; /* A.B.C.D.E packed as a24.b10.c10.d10.e10 */

oh fugly
something like

   dim a as uint32 = bitwise.shiftright(version, 40) and &hFFF
   dim b as uint32 = bitwise.shiftright(version, 30) and &hC8
   dim c as uint32 = bitwise.shiftright(version, 20) and &hC8
   dim d as uint32 = bitwise.shiftright(version, 10) and &hC8
   dim e as uint32 = version and &hC8
1 Like

Thanks Norman.

The version is 1583301038964736

And the result from other tools is “1440.4.0.0.0”.

note that is 100% untested and written only the the text editor here :slight_smile:

ah ok gimme a sec

1 Like

This is when I wish I’d studied CS!

OH DUH me !!!
wrong bit mask
this should work

edited - this should be right now

Thanks man, if you don’t mind me asking, how’d you end up with the values for the bit mask. I don’t understand that at all!

ah ok
while the mask is written in hex it could be written in binary
that would make it clearer

   dim a as uint32 = bitwise.shiftright(version, 40) and &b111111111111111111111111
   dim b as uint32 = bitwise.shiftright(version, 30) and &b1111111111
   dim c as uint32 = bitwise.shiftright(version, 20) and &b1111111111
   dim d as uint32 = bitwise.shiftright(version, 10) and &b1111111111
   dim e as uint32 = version and &b1111111111

a is “24 bits” - the lowest 24 bits when we shift everything right 40 positions
the rest are 10 bits - the lowest 10 bits when we shift everything

then I just wrote the mask in hex instead of binary

do you know how to do that ?

2 Likes

Ahhhhh!! Thank you… This makes sense now… And I guess I just hosed any credibility!

not al all
knowing this sort of low level stuff isnt necessary to be a good developer :slight_smile:

Gracias Señor <whileBowing/>