code: private double convertToDouble(byte[] bin){
          ByteBuffer bb = ByteBuffer.wrap(bin);
          bb.order(ByteOrder.BIG_ENDIAN);
          if(bin.length < 4)
              return bb.getShort();
          else if(bin.length < 8)
              return bb.getInt();
          else
              return bb.getDouble();
      }
docs: Convert binary data to double datatype