Example usage for java.lang Float MAX_VALUE

List of usage examples for java.lang Float MAX_VALUE

Introduction

In this page you can find the example usage for java.lang Float MAX_VALUE.

Prototype

float MAX_VALUE

To view the source code for java.lang Float MAX_VALUE.

Click Source Link

Document

A constant holding the largest positive finite value of type float , (2-2-23)·2127.

Usage

From source file:io.github.hidroh.materialistic.widget.PeekabooTouchHelperCallback.java

@Override
public float getSwipeEscapeVelocity(float defaultValue) {
    return Float.MAX_VALUE;
}

From source file:edu.snu.leader.hidden.builder.BiDirectionalIndividualBuilder.java

/**
 * Creates a preferred direction using a random value drawn from a
 * Gaussian distribution/*from w  ww .  ja v  a  2  s  .co m*/
 *
 * @return The direction
 * @see edu.snu.leader.hidden.builder.AssertivenessAndDirectionIndividualBuilder#createGaussianDirection()
 */
@Override
protected float createGaussianDirection() {
    // Random number generator
    MersenneTwisterFast random = _simState.getRandom();

    int tries = 0;
    float direction = Float.MAX_VALUE;
    while (((_minDirection > direction) || (_maxDirection < direction)) && (_maxTries > tries)) {
        direction = _directionMean + ((float) random.nextGaussian() * _directionStdDev);

        // Apply either a positive or negative delta
        float delta = _dirDelta;
        if (random.nextFloat() > _positiveDeltaProbability) {
            delta *= -1.0f;
        }
        direction += delta;

        tries++;
    }
    if (_maxDirection < direction) {
        direction = _maxDirection;
    } else if (_minDirection > direction) {
        direction = _minDirection;
    }

    return direction;
}

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  ww w  . ja v a  2  s.co m
        }
        if (values[i] > max) {
            max = values[i];
        }
    }
    _minValue = Float.valueOf(min);
    _maxValue = Float.valueOf(max);
}

From source file:edu.stanford.slac.archiverappliance.PB.data.BoundaryConditionsSimulationValueGenerator.java

/**
 * Get a value based on the DBR type. //  ww  w  .j a v  a2s . 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: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();
                    }//from  w w  w  .j a  v a 2s. co  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 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:org.apache.nifi.csv.CSVSchemaInference.java

private DataType getDataType(final String value) {
    if (value == null || value.isEmpty()) {
        return null;
    }//ww w  .j a  v  a2  s.  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:com.android.contacts.util.MaterialColorMapUtils.java

/**
 * Return primary and secondary colors from the Material color palette that are similar to
 * {@param color}./*from   www . j av a 2  s  .  c o  m*/
 */
public MaterialPalette calculatePrimaryAndSecondaryColor(int color) {
    Trace.beginSection("calculatePrimaryAndSecondaryColor");

    final float colorHue = hue(color);
    float minimumDistance = Float.MAX_VALUE;
    int indexBestMatch = 0;
    for (int i = 0; i < sPrimaryColors.length(); i++) {
        final int primaryColor = sPrimaryColors.getColor(i, 0);
        final float comparedHue = hue(primaryColor);
        // No need to be perceptually accurate when calculating color distances since
        // we are only mapping to 15 colors. Being slightly inaccurate isn't going to change
        // the mapping very often.
        final float distance = Math.abs(comparedHue - colorHue);
        if (distance < minimumDistance) {
            minimumDistance = distance;
            indexBestMatch = i;
        }
    }

    Trace.endSection();
    return new MaterialPalette(sPrimaryColors.getColor(indexBestMatch, 0),
            sSecondaryColors.getColor(indexBestMatch, 0));
}

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  v a 2  s .  co  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);
            }
        }
    }
}

From source file:org.deeplearning4j.clustering.cluster.ClusterSet.java

/**
 *
 * @param point//from  w w w .ja  v  a2 s  . c  o m
 * @return
 */
public Pair<Cluster, Double> nearestCluster(Point point) {

    Cluster nearestCluster = null;
    double minDistance = isInverse() ? Float.MIN_VALUE : Float.MAX_VALUE;

    double currentDistance;
    for (Cluster cluster : getClusters()) {
        currentDistance = cluster.getDistanceToCenter(point);
        if (isInverse()) {
            if (currentDistance > minDistance) {
                minDistance = currentDistance;
                nearestCluster = cluster;
            }
        } else {
            if (currentDistance < minDistance) {
                minDistance = currentDistance;
                nearestCluster = cluster;
            }
        }

    }

    return Pair.of(nearestCluster, minDistance);

}

From source file:net.sourceforge.msscodefactory.cflib.v1_11.CFLib.Swing.CFJFloatEditor.java

public void setMaxValue(Float value) {
    final String S_ProcName = "setMaxValue";
    if (value == null) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 1, "value");
    }//from ww w  .j a va 2  s .co m
    if (value.compareTo(Float.MAX_VALUE) > 0) {
        throw CFLib.getDefaultExceptionFactory().newArgumentOverflowException(getClass(), S_ProcName, 1,
                "value", value, Float.MAX_VALUE);
    }
    maxValue = value;
}