Click here to Skip to main content
15,892,809 members

Comments by Yves Goergen (Top 4 by date)

Yves Goergen 20-Jun-18 6:18am View    
Not the bytes are negative. Bytes are never negative, they range from 0 to 255. The complete integer number is negative. And I have the bytes that represent that number.
Yves Goergen 20-Jun-18 5:44am View    
And stupid me, the array length can only be 1, 2, 4 or 8, not 16. Your code doesn't work for me. When I replace '< 0' with '>= 0x80', it produces even higher positive values, longer than possible with 16 bit.
Yves Goergen 20-Jun-18 5:41am View    
Ehm, sorry, this is a Uint8Array, so no negative bytes here.
Yves Goergen 20-Jun-18 5:00am View    
The code is decoding a big-endian unsigned integer in its current form. It does not decode a signed integer. For example -200 as int16 is encoded as FF 38, and this code then decodes it to 65336.