Return the largest double that rounds down to this float.
<p>
Note: Probably not always correct - subnormal values are quite tricky. So
some of the bounds might not be tight.

@param f Float value
@return Double value
967490
public static double floatToDoubleUpper(float f) {
    if(Float.isNaN(f)) {
      return Double.NaN;
    }
    if(Float.isInfinite(f)) {
      return f > 0 ? Double.POSITIVE_INFINITY : Double.longBitsToDouble(0xc7efffffffffffffL);
    }
    long bits = Double.doubleToRawLongBits((double) f);
    if((bits & 0x8000000000000000L) == 0) { // Positive
      if(bits == 0L) {
        return Double.longBitsToDouble(0x3690000000000000L);
      }
      if(f == Float.MIN_VALUE) {
        // bits += 0x7_ffff_ffff_ffffl;
        return Double.longBitsToDouble(0x36a7ffffffffffffL);
      }
      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);
    }
    else {
      if(bits == 0x8000000000000000L) {
        return -0.0d;
      }
      if(f == -Float.MIN_VALUE) {
        // bits -= 0xf_ffff_ffff_ffffl;
        return Double.longBitsToDouble(0xb690000000000001L);
      }
      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);
    }
  }
478238
public static BigDecimal roundHalfEven(BigDecimal value, int scale) {
		return round(value, scale, RoundingMode.HALF_EVEN);
	}
1283163
public double getDouble(String key, double defaultValue) {
		addToDefaults(key, Double.toString(defaultValue));
		String value = get(key);
		if (value == null) {
			return defaultValue;
		} else {
			return Double.valueOf(value);
		}
	}
604333
public double getDouble(String key, double defaultValue) {
    if (containsKey(key)) {
      return Double.parseDouble(get(key));
    } else {
      return defaultValue;
    }
  }
871933
public final double getDouble() {
        if (count == 0) {
            return 0.0;
        }

        StringBuffer temp = getStringBuffer();
        temp.append('.');
        temp.append(digits, 0, count);
        temp.append('E');
        temp.append(decimalAt);
        return Double.parseDouble(temp.toString());
    }
352173
@Override
    public float getFloat(int columnIndex) throws SQLException {
        checkColumnBounds(columnIndex);
        try {
            final VoltType type = table.getColumnType(columnIndex - 1);
            Double doubleValue = null;
            switch(type) {
            case TINYINT:
                doubleValue = new Double(table.getLong(columnIndex - 1));
                break;
            case SMALLINT:
                doubleValue = new Double(table.getLong(columnIndex - 1));
                break;
            case INTEGER:
                doubleValue = new Double(table.getLong(columnIndex - 1));
                break;
            case BIGINT:
                doubleValue = new Double(table.getLong(columnIndex - 1));
                break;
            case FLOAT:
                doubleValue = new Double(table.getDouble(columnIndex - 1));
                break;
            case DECIMAL:
                doubleValue = table.getDecimalAsBigDecimal(columnIndex - 1).doubleValue();
                break;
            default:
                throw new IllegalArgumentException("Cannot get float value for column type '" + type + "'");
            }

            if (table.wasNull()) {
                doubleValue = new Double(0);
            } else if (Math.abs(doubleValue) > new Double(Float.MAX_VALUE)) {
                throw new SQLException("Value out of float range");
            }
            return doubleValue.floatValue();
        } catch (Exception x) {
            throw SQLError.get(x);
        }
    }
1234457
private static function _floatToByte($f)
    {
        // round negatives up to zero
        if ($f <= 0.0) {
            return 0;
        }

        // search for appropriate value
        $lowIndex = 0;
        $highIndex = 255;
        while ($highIndex >= $lowIndex) {
            // $mid = ($highIndex - $lowIndex)/2;
            $mid = ($highIndex + $lowIndex) >> 1;
            $delta = $f - self::$_normTable[$mid];

            if ($delta < 0) {
                $highIndex = $mid-1;
            } elseif ($delta > 0) {
                $lowIndex  = $mid+1;
            } else {
                return $mid; // We got it!
            }
        }

        // round to closest value
        if ($highIndex != 255 
            && $f - self::$_normTable[$highIndex] > self::$_normTable[$highIndex+1] - $f 
        ) {
            return $highIndex + 1;
        } else {
            return $highIndex;
        }
    }
1192364
public double getDouble(int index, double def) {
        Object tmp = mArray.get(index);
        return tmp != null && tmp instanceof Number ? ((Number) tmp)
                .doubleValue() : def;
    }
157025
protected static float truncate(float f, int decimalPlaces) {
        float decimalShift = (float) Math.pow(10, decimalPlaces);
        return Math.round(f * decimalShift) / decimalShift;
    }
1012232
public static double max(final double a, final double b) {
        if (a > b) {
            return a;
        }
        if (a < b) {
            return b;
        }
        /* if either arg is NaN, return NaN */
        if (a != b) {
            return Double.NaN;
        }
        /* min(+0.0,-0.0) == -0.0 */
        /* 0x8000000000000000L == Double.doubleToRawLongBits(-0.0d) */
        long bits = Double.doubleToRawLongBits(a);
        if (bits == 0x8000000000000000L) {
            return b;
        }
        return a;
    }
1212636
public static FloatBinding ulp(final ObservableFloatValue f) {
        return createFloatBinding(() -> Math.ulp(f.get()), f);
    }
904772
public static double[] doublesFrom(InputStream is) {
        ArrayList<Double> doubles = new ArrayList<Double>();
        for (String line : new LineReader(is)) {
            if (line.length() > 0 && !line.startsWith("#"))
                doubles.add(Double.parseDouble(line));
        }
        // copy it, because we can't cast from Double to double...
        double[] ret = new double[doubles.size()];
        for (int i = 0; i < doubles.size(); i++) {
            ret[i] = doubles.get(i);
        }
        return ret;
    }
1350970
public double getDouble(String key, double defaultValue) {
    Object value = get(key);
    if (value instanceof Double) {
      return (double) value;
    }
    if (value instanceof Number) {
      return ((Number) value).doubleValue();
    } else if (value instanceof String) {
      try {
        return Double.valueOf((String) value);
      } catch (NumberFormatException ignored) {
      }
    }
    return defaultValue;
  }
803395
public static FloatBinding nextDown(final ObservableFloatValue f) {
        return createFloatBinding(() -> Math.nextDown(f.get()), f);
    }
1181744
static public function floatsAreEqual($f1, $f2, $maxDiff = 0.005)
    {
        return abs((float) $f2 - (float) $f1) < $maxDiff;
    }
227574
public Double maxF1() 
    {
        double maxF1 = -Double.MAX_VALUE;
        double n = 0;
        for (int i=0; i<pairs.length; i++) {
            if (correctPair(i)) {
                n++;
                double precisionAtRankI = n/(i+1.0);
                double recallAtRankI = n/numCorrectPairs;
                if (precisionAtRankI>0 && recallAtRankI>0) {
                    double f1 = 2*(precisionAtRankI*recallAtRankI) / (precisionAtRankI + recallAtRankI);
                    maxF1 = Math.max( f1, maxF1 );
                }
            }
        }
        return new Double(maxF1);
    }
1119041
public Double getAsDouble(String key) {
        Object value = mValues.get(key);
        try {
            return value != null ? ((Number) value).doubleValue() : null;
        } catch (ClassCastException e) {
            if (value instanceof CharSequence) {
                try {
                    return Double.valueOf(value.toString());
                } catch (NumberFormatException e2) {
                    DLog.e(TAG, "Cannot parse Double value for " + value + " at key " + key);
                    return null;
                }
            } else {
                DLog.e(TAG, "Cannot cast value for " + key + " to a Double: " + value, e);
                return null;
            }
        }
    }