How can I detect negative Hex Values in C#? -


i working on driver temperature sensor. values coming in hex form , stored like:

string temphex = "08c5"; //-> 22,45°c 

the problem is, sensor can notice negative values , have no idea how can detect 2's complement in c#.

maybe can me. thank you!

static public double temp(string hex) {     return convert.toint16(hex,16)*0.01; } 

values 0000 7fff positive, 8000 ffff negative. luckily, convert.toint16() you, how numbers stored internally on modern computers. have multiple 0.01 celsius.


Comments

Popular posts from this blog

Email notification in google apps script -

c++ - Difference between pre and post decrement in recursive function argument -

javascript - IE11 incompatibility with jQuery's 'readonly'? -