List of usage examples for java.lang Float MIN_VALUE
float MIN_VALUE
To view the source code for java.lang Float MIN_VALUE.
Click Source Link
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;//from www .java2 s.c om maxVal = Float.MIN_VALUE; 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:edu.stanford.slac.archiverappliance.PB.data.BoundaryConditionsSimulationValueGenerator.java
/** * Get a value based on the DBR type. /* w w w. j a va 2s. c o m*/ * We should check for boundary conditions here and make sure PB does not throw exceptions when we come close to MIN_ and MAX_ values * @param type * @param secondsIntoYear * @return */ public SampleValue getSampleValue(ArchDBRTypes type, int secondsIntoYear) { switch (type) { case DBR_SCALAR_STRING: return new ScalarStringSampleValue(Integer.toString(secondsIntoYear)); case DBR_SCALAR_SHORT: if (0 <= secondsIntoYear && secondsIntoYear < 1000) { // Check for some numbers around the minimum value return new ScalarValue<Short>((short) (Short.MIN_VALUE + secondsIntoYear)); } else if (1000 <= secondsIntoYear && secondsIntoYear < 2000) { // Check for some numbers around the maximum value return new ScalarValue<Short>((short) (Short.MAX_VALUE - (secondsIntoYear - 1000))); } else { // Check for some numbers around 0 return new ScalarValue<Short>((short) (secondsIntoYear - 2000)); } case DBR_SCALAR_FLOAT: if (0 <= secondsIntoYear && secondsIntoYear < 1000) { // Check for some numbers around the minimum value return new ScalarValue<Float>(Float.MIN_VALUE + secondsIntoYear); } else if (1000 <= secondsIntoYear && secondsIntoYear < 2000) { // Check for some numbers around the maximum value return new ScalarValue<Float>(Float.MAX_VALUE - (secondsIntoYear - 1000)); } else { // Check for some numbers around 0. Divide by a large number to make sure we cater to the number of precision digits return new ScalarValue<Float>((secondsIntoYear - 2000.0f) / secondsIntoYear); } case DBR_SCALAR_ENUM: return new ScalarValue<Short>((short) secondsIntoYear); case DBR_SCALAR_BYTE: return new ScalarValue<Byte>(((byte) (secondsIntoYear % 255))); case DBR_SCALAR_INT: if (0 <= secondsIntoYear && secondsIntoYear < 1000) { // Check for some numbers around the minimum value return new ScalarValue<Integer>(Integer.MIN_VALUE + secondsIntoYear); } else if (1000 <= secondsIntoYear && secondsIntoYear < 2000) { // Check for some numbers around the maximum value return new ScalarValue<Integer>(Integer.MAX_VALUE - (secondsIntoYear - 1000)); } else { // Check for some numbers around 0 return new ScalarValue<Integer>(secondsIntoYear - 2000); } case DBR_SCALAR_DOUBLE: if (0 <= secondsIntoYear && secondsIntoYear < 1000) { // Check for some numbers around the minimum value return new ScalarValue<Double>(Double.MIN_VALUE + secondsIntoYear); } else if (1000 <= secondsIntoYear && secondsIntoYear < 2000) { // Check for some numbers around the maximum value return new ScalarValue<Double>(Double.MAX_VALUE - (secondsIntoYear - 1000)); } else { // Check for some numbers around 0. Divide by a large number to make sure we cater to the number of precision digits return new ScalarValue<Double>((secondsIntoYear - 2000.0) / (secondsIntoYear * 1000000)); } case DBR_WAVEFORM_STRING: // Varying number of copies of a typical value return new VectorStringSampleValue( Collections.nCopies(secondsIntoYear, Integer.toString(secondsIntoYear))); case DBR_WAVEFORM_SHORT: return new VectorValue<Short>(Collections.nCopies(1, (short) secondsIntoYear)); case DBR_WAVEFORM_FLOAT: // Varying number of copies of a typical value return new VectorValue<Float>( Collections.nCopies(secondsIntoYear, (float) Math.cos(secondsIntoYear * Math.PI / 3600))); case DBR_WAVEFORM_ENUM: return new VectorValue<Short>(Collections.nCopies(1024, (short) secondsIntoYear)); case DBR_WAVEFORM_BYTE: // Large number of elements in the array return new VectorValue<Byte>( Collections.nCopies(65536 * secondsIntoYear, ((byte) (secondsIntoYear % 255)))); case DBR_WAVEFORM_INT: // Varying number of copies of a typical value return new VectorValue<Integer>( Collections.nCopies(secondsIntoYear, secondsIntoYear * secondsIntoYear)); case DBR_WAVEFORM_DOUBLE: // Varying number of copies of a typical value return new VectorValue<Double>( Collections.nCopies(secondsIntoYear, Math.sin(secondsIntoYear * Math.PI / 3600))); case DBR_V4_GENERIC_BYTES: // Varying number of copies of a typical value ByteBuffer buf = ByteBuffer.allocate(1024 * 10); buf.put(Integer.toString(secondsIntoYear).getBytes()); buf.flip(); return new ByteBufSampleValue(buf); default: throw new RuntimeException("We seemed to have missed a DBR type when generating sample data"); } }
From source file:net.sourceforge.msscodefactory.cflib.v1_11.CFLib.Swing.CFJFloatEditor.java
public void setMinValue(Float value) { final String S_ProcName = "setMinValue"; if (value == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 1, "value"); }/*from w w w. j a v a 2 s . c om*/ if (value.compareTo(Float.MIN_VALUE) < 0) { throw CFLib.getDefaultExceptionFactory().newArgumentUnderflowException(getClass(), S_ProcName, 1, "value", value, Float.MIN_VALUE); } minValue = value; }
From source file:com.linkedin.pinot.core.realtime.converter.stats.RealtimeNoDictionaryColStatistics.java
private void computeFloatMinMax(int[] rows) { float values[] = new float[_numDocIds]; _blockValSet.getFloatValues(rows, 0, _numDocIds, values, 0); float min = Float.MAX_VALUE; float max = Float.MIN_VALUE; for (int i = 0; i < _numDocIds; i++) { if (values[i] < min) { min = values[i];/*from w w w . ja va2 s .co m*/ } if (values[i] > max) { max = values[i]; } } _minValue = Float.valueOf(min); _maxValue = Float.valueOf(max); }
From source file:org.aksw.gerbil.bat.annotator.NERDAnnotator.java
@Override public HashSet<Annotation> solveA2W(String text) throws AnnotationException { return ProblemReduction.Sa2WToA2W(solveSa2W(text), Float.MIN_VALUE); }
From source file:org.blockartistry.mod.DynSurround.util.ConfigProcessor.java
public static void process(final Configuration config, final Class<?> clazz, final Object parameters) { for (final Field field : clazz.getFields()) { final Parameter annotation = field.getAnnotation(Parameter.class); if (annotation != null) { final String category = annotation.category(); final String property = annotation.property(); final String comment = field.getAnnotation(Comment.class) != null ? field.getAnnotation(Comment.class).value() : "NEEDS COMMENT"; try { final Object defaultValue = field.get(parameters); if (defaultValue instanceof Boolean) { field.set(parameters, config.getBoolean(property, category, Boolean.valueOf(annotation.defaultValue()), comment)); } else if (defaultValue instanceof Integer) { int minInt = Integer.MIN_VALUE; int maxInt = Integer.MAX_VALUE; final MinMaxInt mmi = field.getAnnotation(MinMaxInt.class); if (mmi != null) { minInt = mmi.min(); maxInt = mmi.max(); }/*ww w .j a v a 2s . com*/ field.set(parameters, config.getInt(property, category, Integer.valueOf(annotation.defaultValue()), minInt, maxInt, comment)); } else if (defaultValue instanceof Float) { float minFloat = Float.MIN_VALUE; float maxFloat = Float.MAX_VALUE; final MinMaxFloat mmf = field.getAnnotation(MinMaxFloat.class); if (mmf != null) { minFloat = mmf.min(); maxFloat = mmf.max(); } field.set(parameters, config.getFloat(property, category, Float.valueOf(annotation.defaultValue()), minFloat, maxFloat, comment)); } else if (defaultValue instanceof String) { field.set(parameters, config.getString(property, category, annotation.defaultValue(), comment)); } else if (defaultValue instanceof String[]) { field.set(parameters, config.getStringList(property, category, StringUtils.split(annotation.defaultValue(), ','), comment)); } // Configure restart settings final Property prop = config.getCategory(category).get(property); if (field.getAnnotation(RestartRequired.class) != null) { final RestartRequired restart = field.getAnnotation(RestartRequired.class); prop.setRequiresMcRestart(restart.server()); prop.setRequiresWorldRestart(restart.world()); } else { prop.setRequiresMcRestart(false); prop.setRequiresWorldRestart(false); } prop.setShowInGui(field.getAnnotation(Hidden.class) == null); } catch (final Throwable t) { ModLog.error("Unable to parse configuration", t); } } } }
From source file:net.sourceforge.msscodefactory.cflib.v1_11.CFLib.Swing.CFJDoubleEditor.java
public void setMinValue(Double value) { final String S_ProcName = "setMinValue"; if (value == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 1, "value"); }//from w w w. j a v a2s .c o m if (value.compareTo(Double.MIN_VALUE) < 0) { throw CFLib.getDefaultExceptionFactory().newArgumentUnderflowException(getClass(), S_ProcName, 1, "value", value, Float.MIN_VALUE); } minValue = value; }
From source file:org.aksw.gerbil.bat.annotator.FOXAnnotator.java
@Override public HashSet<Annotation> solveD2W(String text, HashSet<Mention> mentions) throws AnnotationException { return ProblemReduction.Sa2WToD2W(solveSa2W(text), mentions, Float.MIN_VALUE); }
From source file:org.apache.nifi.csv.CSVSchemaInference.java
private DataType getDataType(final String value) { if (value == null || value.isEmpty()) { return null; }/* w w w . j a va 2s . c om*/ if (NumberUtils.isParsable(value)) { if (value.contains(".")) { try { final double doubleValue = Double.parseDouble(value); if (doubleValue > Float.MAX_VALUE || doubleValue < Float.MIN_VALUE) { return RecordFieldType.DOUBLE.getDataType(); } return RecordFieldType.FLOAT.getDataType(); } catch (final NumberFormatException nfe) { return RecordFieldType.STRING.getDataType(); } } try { final long longValue = Long.parseLong(value); if (longValue > Integer.MAX_VALUE || longValue < Integer.MIN_VALUE) { return RecordFieldType.LONG.getDataType(); } return RecordFieldType.INT.getDataType(); } catch (final NumberFormatException nfe) { return RecordFieldType.STRING.getDataType(); } } if (value.equalsIgnoreCase("true") || value.equalsIgnoreCase("false")) { return RecordFieldType.BOOLEAN.getDataType(); } final Optional<DataType> timeDataType = timeValueInference.getDataType(value); return timeDataType.orElse(RecordFieldType.STRING.getDataType()); }
From source file:org.blockartistry.lib.ConfigProcessor.java
public static void process(@Nonnull final Configuration config, @Nonnull final Class<?> clazz, @Nullable final Object parameters) { for (final Field field : clazz.getFields()) { final Parameter annotation = field.getAnnotation(Parameter.class); if (annotation != null) { final String category = annotation.category(); final String property = annotation.property(); final String language = annotation.lang(); final String comment = field.getAnnotation(Comment.class) != null ? field.getAnnotation(Comment.class).value() : "NEEDS COMMENT"; try { final Object defaultValue = field.get(parameters); if (defaultValue instanceof Boolean) { field.set(parameters, config.getBoolean(property, category, Boolean.valueOf(annotation.defaultValue()), comment)); } else if (defaultValue instanceof Integer) { int minInt = Integer.MIN_VALUE; int maxInt = Integer.MAX_VALUE; final MinMaxInt mmi = field.getAnnotation(MinMaxInt.class); if (mmi != null) { minInt = mmi.min(); maxInt = mmi.max(); }/*from w w w . j a va2 s. c o m*/ field.set(parameters, config.getInt(property, category, Integer.valueOf(annotation.defaultValue()), minInt, maxInt, comment)); } else if (defaultValue instanceof Float) { float minFloat = Float.MIN_VALUE; float maxFloat = Float.MAX_VALUE; final MinMaxFloat mmf = field.getAnnotation(MinMaxFloat.class); if (mmf != null) { minFloat = mmf.min(); maxFloat = mmf.max(); } field.set(parameters, config.getFloat(property, category, Float.valueOf(annotation.defaultValue()), minFloat, maxFloat, comment)); } else if (defaultValue instanceof String) { field.set(parameters, config.getString(property, category, annotation.defaultValue(), comment)); } else if (defaultValue instanceof String[]) { field.set(parameters, config.getStringList(property, category, StringUtils.split(annotation.defaultValue(), ','), comment)); } // Configure other settings final Property prop = config.getCategory(category).get(property); if (!StringUtils.isEmpty(language)) prop.setLanguageKey(language); if (field.getAnnotation(RestartRequired.class) != null) { final RestartRequired restart = field.getAnnotation(RestartRequired.class); prop.setRequiresMcRestart(restart.server()); prop.setRequiresWorldRestart(restart.world()); } else { prop.setRequiresMcRestart(false); prop.setRequiresWorldRestart(false); } prop.setShowInGui(field.getAnnotation(Hidden.class) == null); } catch (final Throwable t) { LibLog.log().error("Unable to parse configuration", t); } } } }