On Feb 21, 12:28 am, Mattias Sjögren <mattias.dont.want.s...@mvps.org>
wrote:
> >I can only believe I have to be doing something wrong here...it has to
> >be something simple no?
>
> If you have it as a literal in your code you can do
>
> shorts = unchecked((short)0x8000);
>
> If you get it as ahexformatted string you do
>
> s = unchecked((short)Convert.ToUInt16("8000", 16));
>
> Mattias
>
> --
> Mattias Sjögren [C# MVP] mattias @ mvps.orghttp://www.msjogren.net/dotnet/|http://www.dotnetinterop.com
> Please reply only to the newsgroup.
Ah yes it worked...!!! Thanks so much It was driving me nuts.
On a side note I did get following below to work...though it makes no
sense why the side step worked...but it did. Your way is exactly what
I was looking for (and will be using)
(assume input is unsigned short 0x8000, and output is short)
int temp = Convert.ToInt32(( input | 0xFFFF0000 ) >> 8);
output = Convert.ToInt16((temp << 8) + (input & 0x00FF));
return output;
Thanks to all for the help.