|
Okay, its a new day lets look at this again.
using hex 0x12345678 = 305419896 that
gives us an array of bytes:
Byte: 120
Byte: 86
Byte: 52
Byte: 18
(If I am thinking correctly)Switching this from little endian to big endian
we would need to basically reverse the order of the bytes:
Byte: 18
Byte: 52
Byte: 86
Byte: 120
which is hex 0x78563412 = 2018915346
val = (val >> 8) | (val << 8) gives us:
Byte: 86
Byte: 124
Byte: 86
Byte: 52
which is hex 0x34567C56 = 878083158
Using your -val = (val >> 8) | (val << 8)- we are shifting bits, but I didn't think that is what
the problem is. For assumption was that big and little endian determined which way the bytes were
laid out. For example: 0x12345678 has 4 bytes(32-bits)-bytes:Z=120,Y=86,X=52,W=18. Now this is in
little endian basically because this machine uses little endian. Or in other words the bytes are read right to left in a least to greatest manner. Say that big endian is the opposite, then big read left to right in a least to greatest manner also. Big endian byte arrangement to 0x12345678 would be: W=18, X=52, Y=86, Z=120.
I am questioning things not to be a pain, but to make sure I understand. It seems to me that your are trying to shift bits when what is need is the bytes' order to be reversed. Yes/No
God Bless,
Jason
DavidCrow wrote: It would not affect me or my family one iota. My wife and I are in charge of when the tv is on, and what it displays.
I do not need any external input for that.
|
|
|
|
|
Hi,
the example I gave was handling unsigned shorts, these hold two bytes, hence the
formula included just one OR operator.
For (unsigned) ints, you need to swap 4 bytes, hence 3 OR operators; plus some
masking to avoid bit aliasing.
You could also do it pseudo-recursively like so:
// Swaps all bytes of a uint
public static uint Swap(uint val) {
return (uint)( swapLowerTwoBytes(val)<<16 | swapLowerTwoBytes(val>>16) );
}
// Swaps a ushort (but accepts and returns it as a uint)
public static uint swapLowerTwoBytes(uint val) {
ushort sval=(ushort)val; // throw away top bytes
return (ushort) ( (sval<8) | (sval>8) );
}
Both methods look very similar, I added the (uint) cast for clarity although
it is not needed; both (ushort) casts are necessary to throw away irrelevant bytes.
For signed int, it is similar, but be careful the sign bit gets replicated when
shifting right; either use an explicit AND, or cast to unsigned first.
Hope this helps.
BTW: when I told you to use a recognizable hex test value, the basic idea
is to do all printout in hex too !
|
|
|
|
|
Thank you for the time you spent on this matter.
I think we've got it worked out.
God Bless,
Jason
DavidCrow wrote: It would not affect me or my family one iota. My wife and I are in charge of when the tv is on, and what it displays.
I do not need any external input for that.
|
|
|
|
|
You are welcome.
I hope you are sure you understand the problem and the solutions (with and
without byte array).
|
|
|
|
|
Never mind I got it:
return val = (val >> 24) |(val << 24);
Yep your right that is better.
Thanks for the time and help.
God Bless,
Jason
DavidCrow wrote: It would not affect me or my family one iota. My wife and I are in charge of when the tv is on, and what it displays.
I do not need any external input for that.
|
|
|
|
|
?????????
what is val's type ? what did you do to my code, now it is completely wrong.
[1]
ushort val=0x1234 ?
val>>24=0
val<<24=0
so it returns 0
[2]
uint val=0x12345678 ?
val>>24=0x00000012
val<<24=0x78000000
so it returns 0x78000012 ????
?????????
|
|
|
|
|
Well after some searching on the subject I got it figured out.
Here is what I am using to do the flipping it should handle any size:
static byte[] FlipBytes(byte[] bArray)
{
byte[] bNewArray = new byte[bArray.Length];
int j = 0;
for (int i = bArray.Length - 1; i >= 0; i--)
{
bNewArray[j] = bArray[i];
j++;
}
return bNewArray;
}
God Bless,
Jason
DavidCrow wrote: It would not affect me or my family one iota. My wife and I are in charge of when the tv is on, and what it displays.
I do not need any external input for that.
|
|
|
|
|
I am using Publish Feature of Microsoft Visual Studio 2005(Visual C#) , I can easily Publish and install the updates with one click, BUT the PROBLEM is that it downloads the updates under the Logged-on user profile as C:\Documents and Settings\salman\Local Settings\Apps\2.0\MZ4LCEX9.335\8Q3D2HW5.Q2O\manifests\....
Whereas, i want to specify a download location during publishing the project.
Please help me this is very very urgent.
thanks.
|
|
|
|
|
You posted the same question just a few minutes ago. Please delete the previous post.
__________________
Bob is my homeboy.
|
|
|
|
|
You can't specify install directory on client if you use ClickOnce... If that is absolutely necessary, well -> then you'll have to use some other deployment technology.
However, if you provide me with more info on what you're trying to achieve, I'm willing to give you more suggestions.
Enjoy!
|
|
|
|
|
Hi all,
Ive been using log4net as my logging framework of choice anybody who has used it will agree its really great ! (beats the microsoft logging block)
Now my question ?
I would like to add a SMS Appender feature that will send an sms to a mobile phone as an addtional logging feature, how do i go about adding appenders of my choice ?
Thanks !
|
|
|
|
|
|
|
I am using Publish Feature of Microsoft Visual Studio 2005(Visual C#) , I can easily Publish and install the updates with one click, BUT the PROBLEM is that it downloads the updates under the Logged-on user profile as C:\Documents and Settings\salman\Local Settings\Apps\2.0\MZ4LCEX9.335\8Q3D2HW5.Q2O\manifests\....
Whereas, i want to specify a download location during publishing the project.
Please help me this is very very urgent.
thanks.
|
|
|
|
|
Hello,
i'd like to remove the pointer of the datagridview, i don't know exactly the name of that.
look the picture:
http://img105.imageshack.us/my.php?image=pointerua1.jpg
thank you !!
|
|
|
|
|
Don't keep reposting the same question.
only two letters away from being an asset
|
|
|
|
|
the other post was deleted
|
|
|
|
|
FernandoMartin wrote: i'd like to remove the pointer of the datagridview, i don't know exactly the name of that.
Set the RowHeadersVisible property of the DataGridView to False
|
|
|
|
|
|
how can i code to check for the existence of a particular text file in a drive and then call for a dialogue form if the file does not exist
ma coding life
|
|
|
|
|
Hello,
ploxy wrote: how can i code to check for the existence of a particular text file in a drive
Have a look at System.IO.File namespace and "Exists" method.
ploxy wrote: and then call for a dialogue form if the file does not exist
The System.Windows.Forms.MessageBox with it's static "Show" method will do that.
Hope it helps!
All the best,
Martin
|
|
|
|
|
if (!File.Exists(filename)) {
filename=null;
using (OpenFileDialog dlg=new OpenFileDialog()) {
... dlg properties = values;
if (dlg.Show()==DialogResult.OK) filename=dlg.FileName;
}
}
if (filename!=null) ...
|
|
|
|
|
i wrote a little application that install a particular file in drive C. on installing the application on D drive,i had problem calling the file.how can i code for the file to be referenced irrespective of its installation path
ma coding life
|
|
|
|
|
The only idea I can think of involves creating a share folder where you write the file to. Then you could access the file via the share name. So it would be something like:
\\computername\sharefoldername\file
Of course the down side to this is you need to know the computer name, but that isn't real hard to figure out.
Hope that helps.
Ben
|
|
|
|
|
only two letters away from being an asset
|
|
|
|