I am re-writing a Java Code to Java Script and i got into this Bit operation that doesn't work the same, here is the original Java Code:
ByteArrayOutputStream bos = new ByteArrayOutputStream();
bos.reset();
short x = 451;
bos.write(x & 0xFF);
byte[] bytesArr = bos.toByteArray();
which gives me the one cell sized array: [-61]
this is the JavaScript Code:
var bos = [];
var x = 451;
bos.push(x & 0xFF);
this gives me the one cell sized array: [195]
I have a few more numbers besides the 451 and the transformation works fine for them, what am I missing?