2
Answers

Swapping order of bits:

Glenn Patton

Glenn Patton

12y
1k
1

Hi All,

I have a problem reading back some data from a device, I get back a string "19000000" this string needs to be in the order "00000019" ie reversed but
as it is a string of data it needs to be ordered differently from the obvious reversal method  if you follow me 

 bit heading      87 65 43 21 
returned          19 00 00 00

order wanted   00 00 00 19  
bit heading      21 43 65 87


I have done the following:

for (int i = 0; i <= value_split.Length; i += 2)

{

if (i == value_split.Length)

{

break;

}

Credit_Value_Correct[a] += value_split.Substring(i, 2);

a++;

}

textBox1.Text = Credit_Value_Correct[3] + Credit_Value_Correct[2] + Credit_Value_Correct[1] + Credit_Value_Correct[0];

}

While this appears to work is there a better, more proper way of altering the big-endian to little-endian in C#?

Thanks Glenn  



 


 

Answers (2)
0
Robert Loper
NA 3 1.2k 13y
I Have been considering the problem with editing text and drawing editable graphics to an Image. I believe the approach I am going to take is to implement a layer drawing system, I just need to work out the transparency implementation, I know transparancy doesn't truly exist, even at the system level. but I believe it can be faked well. then I know I can save my layered image as a composite. Does this all sound like a good approach??? please any help???