Hello,
Not sure If I'm posting in the correct group here, so I appologize in
advance if I selected the wrong one.
I am trying to initialize a short with a hex value... sounds trivial
right? Well I have not found a way to do this in c# without the
compiler complaining or throwing a exception when its executing the
code.
The only tricky thing here is that the hex number is acutally a
negative number. I can convert ALL of the positive numbers just fine
as you would expect, I have do nothing other than
Convert.ToInt16(<hexnumber>); (assuming hex number is in range)
Without getting into boring specifics of why its delivered to me this
way, utlimatly what I am trying to do is get the C# equivalent to
the C++ code:
short x = 0x8000;
In C++ This will produce a value of -32768 (which is what I would
expect), In C# it will not compile and when properly formatted still
yields a overflow exception. Here is what I tried:
short x = Convert.ToInt16(0x8000); (results in overflow exception)
Or even
short x = Convert.ToInt16(0xFFFF8000); (results in overflow exception,
reason I used 0xFFFF8000 is because it was the value of Int16.MinValue
in hex according to the autos in VS.NET)
I can only believe I have to be doing something wrong here...it has to
be something simple no?