@@ -181,9 +181,9 @@ public Object getNext(Object array, int pt) throws Exception {
181181 if (array == null ) {
182182 switch (b ) {
183183 case FLOAT32 :
184- return Float .valueOf (doc .readFloat ());
184+ return Double .valueOf (doc .readFloat ());
185185 case FLOAT64 :
186- return Float .valueOf (( float ) doc .readDouble ());
186+ return Double .valueOf (doc .readDouble ());
187187 case UINT8 :
188188 return Integer .valueOf (doc .readUInt8 ());
189189 case UINT16 :
@@ -203,17 +203,17 @@ public Object getNext(Object array, int pt) throws Exception {
203203 case STR8 :
204204 return doc .readString (doc .readUInt8 ());
205205 case STR16 :
206- return doc .readString (doc .readShort ());
206+ return doc .readString (doc .readUnsignedShort ());
207207 case STR32 :
208208 return doc .readString (doc .readInt ());
209209 }
210210 } else {
211211 switch (b ) {
212212 case FLOAT32 :
213- ((float []) array )[pt ] = doc .readFloat ();
213+ ((double []) array )[pt ] = doc .readFloat ();
214214 break ;
215215 case FLOAT64 :
216- ((float []) array )[pt ] = ( float ) doc .readDouble ();
216+ ((double []) array )[pt ] = doc .readDouble ();
217217 break ;
218218 case UINT8 :
219219 ((int []) array )[pt ] = doc .readUInt8 ();
@@ -243,10 +243,10 @@ public Object getNext(Object array, int pt) throws Exception {
243243 ((String []) array )[pt ] = doc .readString (doc .readUInt8 ());
244244 break ;
245245 case STR16 :
246- ((String []) array )[pt ] = doc .readString (doc .readShort ());
246+ ((String []) array )[pt ] = doc .readString (doc .readUnsignedShort ());
247247 break ;
248248 case STR32 :
249- ((String []) array )[pt ] = doc .readString (doc .readInt ());
249+ ((String []) array )[pt ] = doc .readString (doc .readInt ()); // technically shoild be unsigned int
250250 break ;
251251 }
252252 }
@@ -267,9 +267,9 @@ private Object getArray(int n) throws Exception {
267267 int [] a = new int [n ];
268268 a [0 ] = ((Integer ) v ).intValue ();
269269 v = a ;
270- } else if (v instanceof Float ) {
271- float [] a = new float [n ];
272- a [0 ] = ((Float ) v ).floatValue ();
270+ } else if (v instanceof Number ) {
271+ double [] a = new double [n ];
272+ a [0 ] = ((Number ) v ).doubleValue ();
273273 v = a ;
274274 } else if (v instanceof String ) {
275275 String [] a = new String [n ];
@@ -296,8 +296,6 @@ private Object getMap(int n) throws Exception {
296296 Map <String , Object > map = new Hashtable <String , Object >();
297297 for (int i = 0 ; i < n ; i ++) {
298298 String key = getNext (null , 0 ).toString ();
299- //Logger.info(key);
300-
301299 Object value = getNext (null , 0 );
302300 if (value == null ) {
303301 //Logger.info("null value for " + key);
@@ -366,10 +364,10 @@ public static Object decode(byte[] b) {
366364 * @param divisor
367365 * @return array of floats
368366 */
369- public static float [] getFloats (byte [] b , int n , float divisor ) {
367+ public static double [] getFloats (byte [] b , int n , float divisor ) {
370368 if (b == null )
371369 return null ;
372- float [] a = new float [n ];
370+ double [] a = new double [n ];
373371 try {
374372 switch ((b .length - 12 ) / n ) {
375373 case 2 :
@@ -522,10 +520,10 @@ public static int[] rldecode32Delta(byte[] b, int n) {
522520 * @param divisor
523521 * @return array of floats
524522 */
525- public static float [] rldecodef (byte [] b , int n , float divisor ) {
523+ public static double [] rldecodef (byte [] b , int n , float divisor ) {
526524 if (b == null )
527525 return null ;
528- float [] ret = new float [n ];
526+ double [] ret = new double [n ];
529527 for (int i = 0 , pt = 3 ; i < n ;) {
530528 int val = BC .bytesToInt (b , (pt ++) << 2 , true );
531529 for (int j = BC .bytesToInt (b , (pt ++) << 2 , true ); --j >= 0 ;)
@@ -545,10 +543,10 @@ public static float[] rldecodef(byte[] b, int n, float divisor) {
545543 * @param divisor
546544 * @return array of floats
547545 */
548- public static float [] unpack16Deltaf (byte [] b , int n , float divisor ) {
546+ public static double [] unpack16Deltaf (byte [] b , int n , float divisor ) {
549547 if (b == null )
550548 return null ;
551- float [] ret = new float [n ];
549+ double [] ret = new double [n ];
552550 for (int i = 0 , pt = 6 , val = 0 , buf = 0 ; i < n ;) {
553551 int diff = BC .bytesToShort (b , (pt ++) << 1 , true );
554552 if (diff == Short .MAX_VALUE || diff == Short .MIN_VALUE ) {
@@ -575,10 +573,10 @@ public static float[] unpack16Deltaf(byte[] b, int n, float divisor) {
575573 * @param divisor
576574 * @return array of floats
577575 */
578- public static float [] unpackf (byte [] b , int nBytes , int n , float divisor ) {
576+ public static double [] unpackf (byte [] b , int nBytes , int n , float divisor ) {
579577 if (b == null )
580578 return null ;
581- float [] ret = new float [n ];
579+ double [] ret = new double [n ];
582580 switch (nBytes ) {
583581 case 1 :
584582 for (int i = 0 , pt = 12 , offset = 0 ; i < n ;) {
0 commit comments