ByteBuffer Entering Double in array
i am using a java application to communicate with a server written in C# the server side looks at a double reading the Most significant byte first to the least. my doubles are being entered into the byte array which i am sending least significant to most significant. why is this, is there an easy way to reverse this?
# 1
> why is this
Because that is the way you wrote the code.
Other than that you might note that unless you have verified that the .Net layout for a double is exactly the same as java then reversing or not isn't going to solve the problem.
> is there an easy way to reverse this?
Send the bytes in the reverse order of the way you are doing it now.
# 2
>>Send the bytes in the reverse order of the way you are doing it now.
this is obvious, but how do i do it.
i already figured it out there is a parameter you can set on the buffer
ByteBuffer byteBuff = ByteBuffer.wrap(packet).order(ByteOrder.LITTLE_ENDIAN); this will reverse the bytes when adding a double to an array it will place the MSB first in the eight byte field.
# 4
> no points for you
Are you serious?
Did you actually expect someone to figure out how you wrote your code and then provide an exact solution despite the fact that you provided absolutely no information as to what you were doing in your code?
I would suggest that you read the following....
http://www.catb.org/~esr/faqs/smart-questions.html