code: public double read_double() throws OtpErlangDecodeException {
          int tag;
  
          // parse the stream
          tag = read1skip_version();
  
          switch (tag) {
          case OtpExternal.newFloatTag: {
              return Double.longBitsToDouble(readBE(8));
          }
          case OtpExternal.floatTag: {
              BigDecimal val;
              int epos;
              int exp;
              final byte[] strbuf = new byte[31];
              String str;
  
              // get the string
              this.readN(strbuf);
              str = OtpErlangString.newString(strbuf);
  
              // find the exponent prefix 'e' in the string
              epos = str.indexOf('e', 0);
  
              if (epos < 0) {
                  throw new OtpErlangDecodeException("Invalid float format: '"
                          + str + "'");
              }
  
              // remove the sign from the exponent, if positive
              String estr = str.substring(epos + 1).trim();
  
              if (estr.substring(0, 1).equals("+")) {
                  estr = estr.substring(1);
              }
  
              // now put the mantissa and exponent together
              exp = Integer.valueOf(estr).intValue();
              val = new BigDecimal(str.substring(0, epos)).movePointRight(exp);
  
              return val.doubleValue();
          }
          default:
              throw new OtpErlangDecodeException(
                      "Wrong tag encountered, expected "
                              + OtpExternal.newFloatTag + ", got " + tag);
          }
      }
docs: Read an Erlang float from the stream.
  
  @return the float value, as a double.
  
  @exception OtpErlangDecodeException
  if the next term in the stream is not a float.