List of usage examples for java.lang Float MAX_VALUE
float MAX_VALUE
To view the source code for java.lang Float MAX_VALUE.
Click Source Link
From source file:com.fredhopper.core.connector.index.generate.validator.FloatAttributeValidator.java
@Override protected void validateValue(final FhAttributeData attribute, final List<Violation> violations) { final Table<Optional<String>, Optional<Locale>, String> values = attribute.getValues(); final Map<Optional<Locale>, String> valueMap = values.row(Optional.empty()); if (CollectionUtils.isEmpty(valueMap) || valueMap.entrySet().size() != 1 || !valueMap.containsKey(Optional.empty())) { rejectValue(attribute, violations, "The \"float\" attribute value cannot be localized."); return;//from w w w. j av a2 s . c o m } final String value = valueMap.get(Optional.empty()); try { if (StringUtils.isBlank(value) || !(Float.parseFloat(value) > 0 && Double.valueOf(Float.MAX_VALUE).compareTo(Double.valueOf(value)) > 0)) { rejectValue(attribute, violations, "The \"float\" attribute value is not in the supported value range."); } } catch (final NumberFormatException ex) { rejectValue(attribute, violations, "The \"float\" attribute value does not have the appropriate format."); } }
From source file:org.apache.hadoop.mapred.GenReduce.java
@Override public void reduce(Text key, Iterator<Text> values, OutputCollector<Text, Text> output, Reporter reporter) throws IOException { FSDataOutputStream out = null;/* w w w .j av a 2s .co m*/ try { int size = 0; FileSystem fs = FileSystem.get(conf); double averageIORate = 0; List<Float> list = new ArrayList<Float>(); String output_dir = conf.get(OUTPUT_DIR_KEY); Path result_file = new Path(output_dir, "results"); if (fs.exists(result_file)) { fs.delete(result_file); } out = fs.create(result_file, true); long nmaps = conf.getLong(NUMBER_OF_MAPS_KEY, NMAPS); long nthreads = conf.getLong(NUMBER_OF_THREADS_KEY, NTHREADS); out.writeChars("-----------------------------\n"); out.writeChars("Number of mapper :\t\t\t" + nmaps + "\n"); out.writeChars("Number of threads :\t\t\t" + nthreads + "\n"); float min = Float.MAX_VALUE; float max = Float.MIN_VALUE; Class<?> clazz = conf.getClass(THREAD_CLASS_KEY, null); if (clazz == null) { throw new IOException("Class " + conf.get(THREAD_CLASS_KEY) + " not found"); } GenThread t = (GenThread) ReflectionUtils.newInstance(clazz, conf); t.reset(); long total_files = 0; long total_processed_size = 0; long total_num_errors = 0; String total_error = ""; TypeReference<Map<String, String>> type = new TypeReference<Map<String, String>>() { }; while (values.hasNext()) { Map<String, String> stat = mapper.readValue(values.next().toString(), type); size++; total_files += Long.parseLong(stat.get("files")); total_processed_size += Long.parseLong(stat.get("size")); total_num_errors += Long.parseLong(stat.get("nerrors")); total_error += stat.get("errors"); double ioRate = Double.parseDouble(stat.get("rate")); if (ioRate > max) max = (float) ioRate; if (ioRate < min) min = (float) ioRate; list.add((float) ioRate); averageIORate += ioRate; t.analyze(stat); } out.writeChars("Number of files processed:\t\t" + total_files + "\n"); out.writeChars("Number of size processed:\t\t" + total_processed_size + "\n"); out.writeChars("Min IO Rate(MB/sec): \t\t\t" + min + "\n"); out.writeChars("Max IO Rate(MB/sec): \t\t\t" + max + "\n"); averageIORate /= size; float temp = (float) 0.0; for (int i = 0; i < list.size(); i++) { temp += Math.pow(list.get(i) - averageIORate, 2); } out.writeChars("Average(MB/sec): \t\t\t" + averageIORate + "\n"); float dev = (float) Math.sqrt(temp / size); out.writeChars("Std. dev: \t\t\t\t" + dev + "\n"); out.writeChars("Total number of errors:\t\t\t" + total_num_errors + "\n"); out.writeChars(total_error); t.output(out); } catch (IOException e) { LOG.error("Error:", e); throw e; } finally { out.close(); } }
From source file:com.redhat.lightblue.metadata.types.DoubleTypeTest.java
@Test public void testCastFloat() { assertTrue(doubleType.cast(Float.MAX_VALUE) instanceof Double); }
From source file:org.nd4j.linalg.api.ops.impl.accum.Max.java
@Override public float zeroFloat() { return -Float.MAX_VALUE; }
From source file:test.uk.co.modularaudio.util.audio.gui.buffervis.BufferVisualiser.java
private void computeMinMax(final float[] buffer, final int numSamples) { minVal = Float.MAX_VALUE; maxVal = Float.MIN_VALUE;/*from ww w .j av a2s . c o m*/ for (int i = 0; i < numSamples; i++) { final float v = buffer[i]; if (Float.isNaN(v) || Float.isInfinite(v)) { continue; } if (v < minVal) minVal = v; if (v > maxVal) maxVal = v; } diff = maxVal - minVal; }
From source file:com.redhat.lightblue.metadata.types.BigDecimalTypeTest.java
@Test public void testCastFloat() { assertTrue(bigDecimalType.cast(Float.MAX_VALUE) instanceof BigDecimal); }
From source file:org.nd4j.linalg.api.ops.impl.accum.Min.java
@Override public float zeroFloat() { return Float.MAX_VALUE; }
From source file:dtu.ds.warnme.app.location.FollowMeLocationSource.java
private void checkEventsProximity(Location location) { if (cachedEvents == null || cachedEvents.isEmpty()) { return;/* w w w.j av a2 s . c o m*/ } Float closestDistance = Float.MAX_VALUE; Event closestEvent = null; for (Event event : cachedEvents) { Float distance = location.distanceTo(event.getLocation()); Float bearing = location.bearingTo(event.getLocation()); if (distance < closestDistance && bearing < 90f) { closestDistance = distance; closestEvent = event; } } if (closestEvent != null && closestDistance < 500f) { locationSourceListener.onApproachingEvent(closestEvent); } }
From source file:com.opensymphony.xwork2.conversion.impl.StringConverterTest.java
public void testFloatToStringConversionPL() throws Exception { // given//from w ww.j av a2 s. c om StringConverter converter = new StringConverter(); Map<String, Object> context = new HashMap<>(); context.put(ActionContext.LOCALE, new Locale("pl", "PL")); // when has max fraction digits Object value = converter.convertValue(context, null, null, null, Float.MIN_VALUE, null); // then does not lose fraction digits assertEquals("0," + StringUtils.repeat('0', 44) + "14", value); // when has max integer digits value = converter.convertValue(context, null, null, null, Float.MAX_VALUE, null); // then does not lose integer digits assertEquals("34028235" + StringUtils.repeat('0', 31), value); // when cannot be represented exactly with a finite binary number value = converter.convertValue(context, null, null, null, 0.1f, null); // then produce the shortest decimal representation that can unambiguously identify the true value of the floating-point number assertEquals("0,1", value); }
From source file:hivemall.regression.PassiveAggressiveRegressionUDTF.java
protected float aggressiveness() { return Float.MAX_VALUE; }