Example usage for java.lang Float MIN_VALUE

List of usage examples for java.lang Float MIN_VALUE

Introduction

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

Prototype

float MIN_VALUE

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

Click Source Link

Document

A constant holding the smallest positive nonzero value of type float , 2-149.

Usage

From source file:fr.immotronic.ubikit.pems.enocean.impl.item.data.EEP0706xxDataImpl.java

public static EEP0706xxDataImpl constructDataFromRecord(JSONObject lastKnownData) {
    if (lastKnownData == null)
        return new EEP0706xxDataImpl(Float.MIN_VALUE, -1, null);

    try {/*from  ww w .  jav a 2  s .  c  om*/
        float supplyVoltage = (float) lastKnownData.getDouble("supplyVoltage");
        int illumination = lastKnownData.getInt("illumination");
        Date date = new Date(lastKnownData.getLong("date"));

        return new EEP0706xxDataImpl(supplyVoltage, illumination, date);
    } catch (JSONException e) {
        Logger.error(LC.gi(), null,
                "constructDataFromRecord(): An exception while building a sensorData from a JSONObject SHOULD never happen. Check the code !",
                e);
        return new EEP0706xxDataImpl(Float.MIN_VALUE, -1, null);
    }
}

From source file:fr.immotronic.ubikit.pems.enocean.impl.item.data.EEP070401DataImpl.java

public static EEP070401DataImpl constructDataFromRecord(JSONObject lastKnownData) {
    if (lastKnownData == null)
        return new EEP070401DataImpl(Float.MIN_VALUE, Float.MIN_VALUE, null);

    try {//w w w.j av  a  2s .com
        float temperature = (float) lastKnownData.getDouble("temperature");
        float relativeHumidity = (float) lastKnownData.getDouble("relativeHumidity");
        Date date = new Date(lastKnownData.getLong("date"));

        return new EEP070401DataImpl(temperature, relativeHumidity, date);
    } catch (JSONException e) {
        Logger.error(LC.gi(), null,
                "constructDataFromRecord(): An exception while building a sensorData from a JSONObject SHOULD never happen. Check the code !",
                e);
        return new EEP070401DataImpl(Float.MIN_VALUE, Float.MIN_VALUE, null);
    }
}

From source file:fr.immotronic.ubikit.pems.enocean.impl.item.data.EEP070904DataImpl.java

public static EEP070904DataImpl constructDataFromRecord(JSONObject lastKnownData) {
    if (lastKnownData == null)
        return new EEP070904DataImpl(Float.MIN_VALUE, -1, Float.MIN_VALUE, null);

    try {/* w w w .j  a v  a  2s . c o m*/
        float relativeHumidity = (float) lastKnownData.getDouble("relativeHumidity");
        int CO2ppm = lastKnownData.getInt("CO2ppm");
        float temperature = (float) lastKnownData.getDouble("temperature");
        Date date = new Date(lastKnownData.getLong("date"));

        return new EEP070904DataImpl(relativeHumidity, CO2ppm, temperature, date);
    } catch (JSONException e) {
        Logger.error(LC.gi(), null,
                "constructDataFromRecord(): An exception while building a sensorData from a JSONObject SHOULD never happen. Check the code !",
                e);
        return new EEP070904DataImpl(Float.MIN_VALUE, -1, Float.MIN_VALUE, null);
    }
}

From source file:fr.immotronic.ubikit.pems.enocean.impl.item.data.EEP070402DataImpl.java

public static EEP070402DataImpl constructDataFromRecord(JSONObject lastKnownData) {
    if (lastKnownData == null)
        return new EEP070402DataImpl(Float.MIN_VALUE, Float.MIN_VALUE, Float.MIN_VALUE, null);

    try {/*from w  w w.  java  2 s . c o m*/
        float supplyVoltage = (float) lastKnownData.getDouble("supplyVoltage");
        float temperature = (float) lastKnownData.getDouble("temperature");
        float relativeHumidity = (float) lastKnownData.getDouble("relativeHumidity");
        Date date = new Date(lastKnownData.getLong("date"));

        return new EEP070402DataImpl(supplyVoltage, temperature, relativeHumidity, date);
    } catch (JSONException e) {
        Logger.error(LC.gi(), null,
                "constructDataFromRecord(): An exception while building a sensorData from a JSONObject SHOULD never happen. Check the code !",
                e);
        return new EEP070402DataImpl(Float.MIN_VALUE, Float.MIN_VALUE, Float.MIN_VALUE, null);
    }
}

From source file:com.jernejerin.traffic.helper.TripOperations.java

/**
 * Parses and validates a trip for erroneous values. It first checks, if parsed string contains
 * 17 values. If it does not, it returns null.
 *
 * If the value is considered erroneous, it is set to the following values:
 *  - primitive types: MIN_VALUE//  w ww  .j  ava  2  s .c o m
 *  - objects: null
 *
 * @param tripValues comma delimited string representing Trip to check
 * @param timestampReceived Timestamp when the event was received
 * @param id id of the event received
 * @return a Trip with erroneous values set to MIN_VALUE, or null if whole trip was malformed
 */
public static Trip parseValidateTrip(String tripValues, long timestampReceived, int id) {
    //        LOGGER.log(Level.INFO, "Started parsing and validating trip = " +
    //                tripValues + " from thread = " + Thread.currentThread());

    // our returned trip
    Trip trip = new Trip();

    // values are comma separated
    String[] tripSplit = tripValues.split(",");

    // if we do not have 17 values, then return null
    if (tripSplit.length != 17)
        return null;

    // check for correct values and then set them
    trip.setId(id);
    trip.setMedallion(tryParseMD5(tripSplit[0], null));
    trip.setHackLicense(tryParseMD5(tripSplit[1], null));
    trip.setPickupDatetime(tryParseDateTime(tripSplit[2], null));
    trip.setDropOffDatetime(tryParseDateTime(tripSplit[3], null));
    trip.setDropOffTimestamp(
            trip.getDropOffDatetime() != null ? trip.getDropOffDatetime().toEpochSecond(ZoneOffset.UTC) * 1000
                    : 0);
    trip.setTripTime(NumberUtils.toInt(tripSplit[4], Integer.MIN_VALUE));
    trip.setTripDistance(NumberUtils.toFloat(tripSplit[5], Integer.MIN_VALUE));
    trip.setPickupLongitude(tryLongitude(tripSplit[6], Float.MIN_VALUE));
    trip.setPickupLatitude(tryLatitude(tripSplit[7], Float.MIN_VALUE));
    trip.setDropOffLongitude(tryLongitude(tripSplit[8], Float.MIN_VALUE));
    trip.setDropOffLatitude(tryLatitude(tripSplit[9], Float.MIN_VALUE));
    trip.setPaymentType(tryPayment(tripSplit[10], null));
    trip.setFareAmount(NumberUtils.toFloat(tripSplit[11], Float.MIN_VALUE));
    trip.setSurcharge(NumberUtils.toFloat(tripSplit[12], Float.MIN_VALUE));
    trip.setMtaTax(NumberUtils.toFloat(tripSplit[13], Float.MIN_VALUE));
    trip.setTipAmount(NumberUtils.toFloat(tripSplit[14], Float.MIN_VALUE));
    trip.setTollsAmount(NumberUtils.toFloat(tripSplit[15], Float.MIN_VALUE));
    trip.setTotalAmount(NumberUtils.toFloat(tripSplit[16], Float.MIN_VALUE));
    trip.setTimestampReceived(timestampReceived);

    // does the coordinate for pickup location lie inside grid
    if (Cell.inGrid(trip.getPickupLatitude(), trip.getPickupLongitude())
            && Cell.inGrid(trip.getDropOffLatitude(), trip.getDropOffLongitude())) {
        trip.setRoute250(new Route(new Cell250(trip.getPickupLatitude(), trip.getPickupLongitude()),
                new Cell250(trip.getDropOffLatitude(), trip.getDropOffLongitude())));
        trip.setRoute500(new Route(new Cell500(trip.getPickupLatitude(), trip.getPickupLongitude()),
                new Cell500(trip.getDropOffLatitude(), trip.getDropOffLongitude())));
    }

    //        LOGGER.log(Level.INFO, "Finished parsing and validating trip = " +
    //                trip.toString() + " from thread = " + Thread.currentThread());
    return trip;
}

From source file:net.sf.jasperreports.engine.util.JRFloatLocaleConverter.java

@Override
protected Object parse(Object value, String pattern) throws ParseException {
    final Number parsed = (Number) super.parse(value, pattern);
    double doubleValue = parsed.doubleValue();
    double posDouble = (doubleValue >= 0) ? doubleValue : (doubleValue * -1);
    if ((posDouble > 0 && posDouble < Float.MIN_VALUE) || posDouble > Float.MAX_VALUE) {
        throw new ConversionException("Supplied number is not of type Float: " + parsed);
    }/* ww  w  .  ja v  a  2 s .c om*/
    return parsed.floatValue(); // unlike superclass it returns Float type
}

From source file:org.joda.primitives.iterator.impl.TestArrayFloatIterator.java

@Override
public Iterator<Float> makeFullIterator() {
    float[] data = new float[] { new Float(2f), new Float(-2f), new Float(38.874f), new Float(0f),
            new Float(10000f), new Float(202f), new Float(Float.MIN_VALUE), new Float(Float.MAX_VALUE) };
    return new ArrayFloatIterator(data);
}

From source file:com.opengamma.maths.lowlevelapi.functions.utilities.Max.java

/**
 * Returns the index of the maximum value in data
 * @param data the data to search//from  ww w  .  j  ava2  s.c  o  m
 * @return idx, the index of the maximum value in the data
 */
public static int index(float... data) {
    Validate.notNull(data);
    float max = Float.MIN_VALUE;
    int idx = -1;
    final int n = data.length;
    for (int i = 0; i < n; i++) {
        if (data[i] > max) {
            max = data[i];
            idx = i;
        }
    }
    return idx;
}

From source file:fr.immotronic.ubikit.pems.enocean.impl.item.data.EEP0708xxDataImpl.java

public static EEP0708xxDataImpl constructDataFromRecord(JSONObject lastKnownData) {
    if (lastKnownData == null)
        return new EEP0708xxDataImpl(Float.MIN_VALUE, -1, Float.MIN_VALUE, PIRStatus.UNKNOWN, null, null);

    try {/*from   w w w. j  a  v  a 2 s.com*/
        float supplyVoltage = (float) lastKnownData.getDouble("supplyVoltage");
        int illumination = lastKnownData.getInt("illumination");
        float temperature = (float) lastKnownData.getDouble("temperature");
        PIRStatus pirStatus = PIRStatus.valueOf(lastKnownData.getString("pirStatus"));
        long LOPBDate = lastKnownData.optLong("LOPBDate");
        Date date = new Date(lastKnownData.getLong("date"));

        return new EEP0708xxDataImpl(supplyVoltage, illumination, temperature, pirStatus,
                (LOPBDate == 0) ? null : new Date(LOPBDate), date);
    } catch (JSONException e) {
        Logger.error(LC.gi(), null,
                "constructDataFromRecord(): An exception while building a sensorData from a JSONObject SHOULD never happen. Check the code !",
                e);
        return new EEP0708xxDataImpl(Float.MIN_VALUE, -1, Float.MIN_VALUE, PIRStatus.UNKNOWN, null, null);
    }
}

From source file:io.galeb.router.tests.hostselectors.GuavaConsistentHashTest.java

@Test
public void checkUniformDistribution() {
    final long samples = 100000L;
    final int rounds = 5;
    final double percentMarginOfError = 0.5;
    final int numKeys = 100;
    final Random random = new Random();

    for (int round = 0; round < rounds; round++) {
        logger.info(String.format("checkUniformDistribution - round %s: %d samples", round + 1, samples));

        for (final HashFunction hash : new HashFunction[] { md5(), murmur3_128(), sipHash24(), sha256() }) {
            long sum = 0L;
            final long initialTime = System.currentTimeMillis();
            for (Integer counter = 0; counter < samples; counter++) {
                final int chosen = (int) (random.nextFloat() * (numKeys - Float.MIN_VALUE));
                sum += Hashing.consistentHash(hash.hashInt(chosen), (int) numBackends);
            }/* w  w w.java  2 s  . co  m*/

            final long finishTime = System.currentTimeMillis();

            final double result = (numBackends * (numBackends - 1) / 2.0) * (samples / numBackends);

            logger.info(String.format(
                    "-> checkUniformDistribution (%s): Time spent (ms): %d. NonUniformDistRatio (smaller is better): %.4f%%",
                    hash, finishTime - initialTime, Math.abs(100.0 * (result - sum) / result)));

            final double topLimit = sum * (1.0 + percentMarginOfError);
            final double bottomLimit = sum * (1.0 - percentMarginOfError);

            try {
                assertThat(result).isGreaterThanOrEqualTo(bottomLimit).isLessThanOrEqualTo(topLimit);
            } catch (AssertionError e) {
                logger.error("Error when testing " + hash);
                throw e;
            }
        }
    }
}