Hi
I am trying to convert scientific double to decimal double in java. I am sending a value from server (coded on C++) which is running on X86 (little endian) machine and I was using htonl, ntohl methods for convertion before sending data to client (coded on java). But now, I have to sent this value with no conversion like LE to BE. The coversion is being done on client (java) side. Other type can be converted correctly but for double, this is not present. When client receive a double type, this value can not be read correctly. Here is my java code for double conversion.
protected int readInt(InputStream stream) throws IOException {
int i0 = read(stream);
int i1 = read(stream);
int i2 = read(stream);
int i3 = read(stream);
int i=(i0 << 24) + (i1 << 16) + (i2 << 8) + (i3 << 0);
return i;
}
protected double readDouble(InputStream stream) throws IOException {
int i0 = readInt(stream);
int i1 = readInt(stream);
return Double.longBitsToDouble(((long)i0 << 32) + (i1 & 0xffffffffL));
}
After all of these steps, I got 9.534475227E-315 if I sent 0.3 from server.
Thanks and regards.