My maths brain has locked up
given a 2 element list [255,254] which in hex represents 0xFFFE and if we assume it's in two's complement == -2
how can I get the two's complement decimal number of any [x,y] list
My maths brain has locked up
given a 2 element list [255,254] which in hex represents 0xFFFE and if we assume it's in two's complement == -2
how can I get the two's complement decimal number of any [x,y] list
The easy way:
unsigned short x=a[0]*1<<8+a[1];
short y=*(*short)&x;
The hard way:
x=a[0]*1<<8+a[1];
if(x&1<<15)x-=1<<16;
(why don't we have pointers and explicit type conversion in snap?)
My brain started working again and I've come up with this
[edit] made a couple of custom reporters to tidy it up
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.