@Test public void testClosestToUpperBoundNotInArray() { try { SpikeInterpolation.getUpperValue(useAr, 100); fail("Can fine the closest max value of 100.0"); } catch (IllegalArgumentException e) { } }
static double getUpperValue(double[] doubles, double val) { double lowestUpper = Double.MAX_VALUE; for (double current : doubles) { if (current >= val && current <= lowestUpper) { lowestUpper = current; } } if (lowestUpper == Double.MAX_VALUE) { throw new IllegalArgumentException("Can't find the closest max value of " + val); } return lowestUpper; }
SpikeInterpolation { static double getUpperValue(double[] doubles, double val) { double lowestUpper = Double.MAX_VALUE; for (double current : doubles) { if (current >= val && current <= lowestUpper) { lowestUpper = current; } } if (lowestUpper == Double.MAX_VALUE) { throw new IllegalArgumentException("Can't find the closest max value of " + val); } return lowestUpper; } }
SpikeInterpolation { static double getUpperValue(double[] doubles, double val) { double lowestUpper = Double.MAX_VALUE; for (double current : doubles) { if (current >= val && current <= lowestUpper) { lowestUpper = current; } } if (lowestUpper == Double.MAX_VALUE) { throw new IllegalArgumentException("Can't find the closest max value of " + val); } return lowestUpper; }  }
SpikeInterpolation { static double getUpperValue(double[] doubles, double val) { double lowestUpper = Double.MAX_VALUE; for (double current : doubles) { if (current >= val && current <= lowestUpper) { lowestUpper = current; } } if (lowestUpper == Double.MAX_VALUE) { throw new IllegalArgumentException("Can't find the closest max value of " + val); } return lowestUpper; }   }
SpikeInterpolation { static double getUpperValue(double[] doubles, double val) { double lowestUpper = Double.MAX_VALUE; for (double current : doubles) { if (current >= val && current <= lowestUpper) { lowestUpper = current; } } if (lowestUpper == Double.MAX_VALUE) { throw new IllegalArgumentException("Can't find the closest max value of " + val); } return lowestUpper; }    }