c# - Convert two UInt16 Values to one UInt32 Value consider least and most significant word -
i have 2 uint16 values
private uint16 leastsignificantword; private uint16 mostsignificantword;
the 2 words (uint16 values) come component divides uint32 status / error value 2 words , returns 2 words. need uint32 value. sum 2 words wouldn't trick because of disregard if , least significant.
for example:
private uint16 leastsignificantword = 1; private uint16 mostsignificantword = 1; //result contains value 2 after sum both words //which can not correct because have take note of , least significant uint32 result = leastsignificantword + mostsignificantword;
is there way solve this? honest have never worked bits / bytes in c# had never faced such problem. in advance
private uint16 leastsignificantword = 1; private uint16 mostsignificantword = 1; uint32 result = (leastsignificantword << 16) + mostsignificantword;
you have 2 uint16 (16 bit , 16 bit) 1 0010 1011 1010 1110
, second 1001 0111 0100 0110
if read 2 uin16 1 uint32 have 0010 1011 1010 1110 1001 0111 0100 0110
so, (leastsignificantword << 16)
gives 0010 1011 1010 1110 0000 0000 0000 0000
, plus mostsignificantword
gives 0010 1011 1010 1110 1001 0111 0100 0110
these can helpful
Comments
Post a Comment