Converts a double value to a sortable long. The value is converted by getting their IEEE 754
floating-point bit layout. Some bits are swapped to be able to compare the result as long.
485330
public static long doubleToSortableLong(double value)
    {
        long bits = Double.doubleToLongBits(value);
        return bits ^ (bits >> 63) & Long.MAX_VALUE;
    }
1317887
private Object toActualNumber(Double value, Type type) {
        if (type.equals(Byte.class)) return value.byteValue();
        if (type.equals(Short.class)) return value.shortValue();
        if (type.equals(Integer.class)) return value.intValue();
        if (type.equals(Long.class)) return value.longValue();
        if (type.equals(Float.class)) return value.floatValue();
        if (type.equals(Double.class)) return value;
        if (type.equals(BigInteger.class)) return BigInteger.valueOf(value.longValue());
        if (type.equals(BigDecimal.class)) return BigDecimal.valueOf(value);

        return value;
    }
634688
public static Double asDouble(Object value) {
    double doubleValue;
    switch (value.getClass().getCanonicalName()) {
      case "java.math.BigDecimal":
        doubleValue = ((BigDecimal) value).doubleValue();
        break;
      case "java.lang.Integer":
        doubleValue = ((Integer) value).doubleValue();
        break;
      default:
        doubleValue = (Double) value;
        break;
    }
    return doubleValue;
  }
263226
private static double convertStringToDouble(final String value) {
    double doubleValue = 0;
    if(!StringUtils.isBlank(value)) {
      try {
        doubleValue = Double.parseDouble(value.trim());
      }
      catch(Exception e) {
        // do nothing
      }
    }
    return doubleValue;
  }
738321
Item newDouble(final double value) {
        key.set(value);
        Item result = get(key);
        if (result == null) {
            pool.putByte(DOUBLE).putLong(key.longVal);
            result = new Item(index, key);
            put(result);
            index += 2;
        }
        return result;
    }
74337
static
	private Float toFloat(Object value){

		if(value instanceof Float){
			return (Float)value;
		} else

		if(value instanceof Double){
			Number number = (Number)value;

			return toFloat(number.floatValue());
		} else

		if((value instanceof Long) || (value instanceof Integer) || (value instanceof Short) || (value instanceof Byte)){
			Number number = (Number)value;

			return toFloat(number.floatValue());
		} else

		if(value instanceof Boolean){
			Boolean flag = (Boolean)value;

			return (flag.booleanValue() ? Numbers.FLOAT_ONE : Numbers.FLOAT_ZERO);
		} else

		if((value instanceof DaysSinceDate) || (value instanceof SecondsSinceDate) || (value instanceof SecondsSinceMidnight)){
			Number number = (Number)value;

			return toFloat(number.floatValue());
		}

		throw new TypeCheckException(DataType.FLOAT, value);
	}
5623
private static double doubleHighPart(double d) {
        if (d > -Precision.SAFE_MIN && d < Precision.SAFE_MIN){
            return d; // These are un-normalised - don't try to convert
        }
        long xl = Double.doubleToLongBits(d);
        xl = xl & MASK_30BITS; // Drop low order bits
        return Double.longBitsToDouble(xl);
    }
1082974
public Long toLong() {
		Long value;
		value = Long.valueOf(this.isNeg ? Long.parseLong(this.param)*-1 : Long.parseLong(this.param));
		return value;
	}
104814
public final long getLong() {
        // for now, simple implementation; later, do proper IEEE native stuff

        if (count == 0) {
            return 0;
        }

        // We have to check for this, because this is the one NEGATIVE value
        // we represent.  If we tried to just pass the digits off to parseLong,
        // we'd get a parse failure.
        if (isLongMIN_VALUE()) {
            return Long.MIN_VALUE;
        }

        StringBuffer temp = getStringBuffer();
        temp.append(digits, 0, count);
        for (int i = count; i < decimalAt; ++i) {
            temp.append('0');
        }
        return Long.parseLong(temp.toString());
    }
146211
static long getLong(ByteBuffer buffer) {
        long v = buffer.get();
        long value = v & 0x7F;
        if ((v & 0x80) != 0) {
            v = buffer.get();
            value |= (v & 0x7F) << 7;
            if ((v & 0x80) != 0) {
                v = buffer.get();
                value |= (v & 0x7F) << 14;
                if ((v & 0x80) != 0) {
                    v = buffer.get();
                    value |= (v & 0x7F) << 21;
                    if ((v & 0x80) != 0) {
                        v = buffer.get();
                        value |= (v & 0x7F) << 28;
                        if ((v & 0x80) != 0) {
                            v = buffer.get();
                            value |= (v & 0x7F) << 35;
                            if ((v & 0x80) != 0) {
                                v = buffer.get();
                                value |= (v & 0x7F) << 42;
                                if ((v & 0x80) != 0) {
                                    v = buffer.get();
                                    value |= (v & 0x7F) << 49;
                                    if ((v & 0x80) != 0) {
                                        v = buffer.get();
                                        value |= v << 56;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        value = (value >>> 1) ^ (-(value & 1));
        return value;
    }
899263
public long toLong(Object val) {
    if (val == null) {
      return 0L;
    }
    else if (val instanceof Double) {
      if (!Double.isNaN(((Double) val).doubleValue())) {
        return 0;
      }
      else {
        return ((Double) val).longValue();
      }
    }
    else if (val instanceof Number) {
      return ((Number) val).longValue();
    }
    else if (val instanceof String) {
      if ("".equals(val)) {
        return 0;
      }
      else {
        return Long.parseLong((String) val);
      }
    }
    else if (val instanceof Boolean) {
      return ((Boolean) val).booleanValue() ? 1L : 0L;
    }
    else if (val instanceof Character) {
      return ((Character) val).charValue();
    }

    throw new ArithmeticException("Long coercion: " + val.getClass().getName() + ":(" + val + ")");
  }
1159946
public Double convertStringToDouble(String value) {
        Double result;
        try {
            result = Double.valueOf(value);
        } catch (NumberFormatException e) {
            result = DEFAULT_DOUBLE_VALUE;
        }
        return result;
    }
567748
public static final Double getDouble(byte[] data, int offset)
   {
      Double result = null;
      long longValue = getLong(data, offset);
      if (longValue != NULL_DOUBLE)
      {
         double doubleValue = Double.longBitsToDouble(longValue);
         if (!Double.isNaN(doubleValue))
         {
            result = Double.valueOf(doubleValue);
         }
      }
      return result;
   }
1290772
public static final long toLong(byte[] b) {
        long x = 0;
        for (int i = b.length; i > 0; x |= (b[--i] & 0xffL) << (i << 3));
        return x;
    }
445272
public double getDouble(final int index, final ByteOrder byteOrder)
    {
        if (SHOULD_BOUNDS_CHECK)
        {
            boundsCheck0(index, SIZE_OF_DOUBLE);
        }

        if (NATIVE_BYTE_ORDER != byteOrder)
        {
            final long bits = UNSAFE.getLong(byteArray, addressOffset + index);
            return Double.longBitsToDouble(Long.reverseBytes(bits));
        }
        else
        {
            return UNSAFE.getDouble(byteArray, addressOffset + index);
        }
    }
479292
public static double floatToDoubleLower(float f) {
    if(Float.isNaN(f)) {
      return Double.NaN;
    }
    if(Float.isInfinite(f)) {
      return f < 0 ? Double.NEGATIVE_INFINITY : Double.longBitsToDouble(0x47efffffffffffffL);
    }
    long bits = Double.doubleToRawLongBits((double) f);
    if((bits & 0x8000000000000000L) == 0) { // Positive
      if(bits == 0L) {
        return +0.0d;
      }
      if(f == Float.MIN_VALUE) {
        // bits -= 0xf_ffff_ffff_ffffl;
        return Double.longBitsToDouble(0x3690000000000001L);
      }
      if(Float.MIN_NORMAL > f /* && f >= Double.MIN_NORMAL */) {
        // The most tricky case:
        // a denormalized float, but a normalized double
        final long bits2 = Double.doubleToRawLongBits((double) -Math.nextUp(-f));
        bits = (bits >>> 1) + (bits2 >>> 1) + 1L; // + (0xfff_ffffL << 18);
      }
      else {
        bits -= 0xfffffffL; // 28 extra bits
      }
      return Double.longBitsToDouble(bits);
    }
    else {
      if(bits == 0x8000000000000000L) {
        return Double.longBitsToDouble(0xb690000000000000L);
      }
      if(f == -Float.MIN_VALUE) {
        // bits += 0x7_ffff_ffff_ffffl;
        return Double.longBitsToDouble(0xb6a7ffffffffffffL);
      }
      if(-Float.MIN_NORMAL < f /* && f <= -Double.MIN_NORMAL */) {
        // The most tricky case:
        // a denormalized float, but a normalized double
        final long bits2 = Double.doubleToRawLongBits((double) -Math.nextUp(-f));
        bits = (bits >>> 1) + (bits2 >>> 1) - 1L;
      }
      else {
        bits += 0xfffffffL; // 28 extra bits
      }
      return Double.longBitsToDouble(bits);
    }
  }
973095
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();
    }