posted 13 years ago
Right Stephan, let me explain the purpose: i got a protocol of communication that specifies some bytes/values.. like this:
bytes[10] (bytes[0..2] is one value that represent one thing, bytes[3..9] represent another thing)... like this, and these 2 methods help me to put a value into a sequence of bytes, like, i want the value "-45" in a byte[] of size 2, so i use the method "longToByteArray(long, 2)" and i receive back this long in a byte[2] so i can put it between bytes[0..2] and bytes[5..9] for example, because when the message be received in the other side the machine will take this bytes[3..4] and convert to a Long using the method byteArrayToLong(bytes, 2, false) for example and must receive the "-45" value...
i tried to use a low value with the modification that you give to me, still not working, like using -45 for example when i run give me this output:
maybe i can change all bits value like all "1" turn "0" and "0" in "1" to change de sign? it can work? please help me.