[ACCEPTED]-Convert an unsigned 16 bit int to a signed 16 bit int in C#-signed
Accepted answer
Have you tried explicit casting?
UInt16 x = 65535;
var y = (Int16)x; // y = -1
0
Using unchecked
here avoids a crash if [X] Check for Arithmetic Overflow
is on:
UInt16 x = 65535;
Int16 y = unchecked((Int16)x);
0
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.