java - parsing error when sending double from android to php with hessian -
java - parsing error when sending double from android to php with hessian -
i want send double value android client php server using hessian either writedouble function on client or parsedouble function on server has error. (we transmit many different info types correctly, double give problem :))
the double values longitude , latitude example:
sent android client: 14,30485725402832
received @ server: 1.0474191691834e-321
android encoding:
public void writedouble(double value) throws ioexception { long bits = double.doubletolongbits(value); os.write('d'); os.write((byte) (bits >> 56)); os.write((byte) (bits >> 48)); os.write((byte) (bits >> 40)); os.write((byte) (bits >> 32)); os.write((byte) (bits >> 24)); os.write((byte) (bits >> 16)); os.write((byte) (bits >> 8)); os.write((byte) (bits)); }
php decoding:
function parsedouble($code, $num){ $bytes = $this->read(8); if(hessianutils::$littleendian) $bytes = strrev($bytes); $double = unpack("dflt", $bytes); homecoming $double['flt']; }
btw: have iphone client send double - works fine ...
iphone encoding:
(void)encodedouble:(double)realv forkey:(nsstring*)key; { if (key) [self writetypedobject:key]; [self writechar:'d']; [self writeint64:(int64_t)(*((double*)(&realv)))]; }
given ios little-endian, think want encode double
in opposite order in java code.
java php hessian
Comments
Post a Comment