No products are associated with this question.
Why are you using uint16 when you have a negative number?????
S = -5; Cw1=dec2bin(typecast(int16(S),'uint16'),15)
S_recovered = bin2dec(Cw1) maxUint16 = intmax('uint16') maxInt16 = intmax('int16') if S_recovered > maxInt16 S_recovered = int16(S_recovered - double(maxUint16) - 1) end
S_recovered will be -5 as a signed 16 bit integer, which is what I assume you want.
Play games and win prizes!Learn more