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.datahandler.EEP070401DataHandler.java

@Override
public void processNewIncomingData(int transmitterID, EnoceanData data) {
    List<AbstractEvent> events = new ArrayList<AbstractEvent>();

    byte[] dataBytes = data.getBytes();

    // Checking if telegram is a teach-in telegram. If so, ignore it.
    if ((dataBytes[0] & 0x8) == 0x0) {
        return;/*from   www  . ja  v  a 2s.com*/
    }

    boolean temperatureSensorPresent = false;
    if ((dataBytes[0] & 0x2) == 0x2) {
        temperatureSensorPresent = true;
    }

    float temperature = Float.MIN_VALUE;

    if (temperatureSensorPresent) {
        // According to Enocean Equipment Profile, temperature = 0..40C, DB1 = 0..250, linear
        temperature = (float) (dataBytes[1] & 0xff) * temperatureMultiplier;

        // Generate a Temperature event.
        events.add(new TemperatureEvent(itemUID, temperature, data.getDate()));
    }

    float relativeHumidity = Float.MIN_VALUE;
    // According to Enocean Equipment Profile, relativeHumidity = 0..100%, DB2 = 0..250, linear
    relativeHumidity = (float) (dataBytes[2] & 0xff) * relativeHumidityMultiplier;

    // Generate and send an relative humidity event.
    events.add(new RelativeHumidityEvent(itemUID, relativeHumidity, data.getDate()));

    // Remembering received data
    sensorData = new EEP070401DataImpl(temperature, relativeHumidity, data.getDate());

    // And then, send all generated events. Sending MUST be done after remembering received data, otherwise if an event listener performs
    // a getLastKnownData() on event reception, it might obtain non up-to-date data.
    eventGate.postEvents(events);
}

From source file:fr.immotronic.ubikit.pems.enocean.impl.item.datahandler.EEP070402DataHandler.java

@Override
public void processNewIncomingData(int transmitterID, EnoceanData data) {
    List<AbstractEvent> events = new ArrayList<AbstractEvent>();

    byte[] dataBytes = data.getBytes();

    // Checking if telegram is a teach-in telegram. If so, ignore it.
    if ((dataBytes[0] & 0x8) == 0x0) {
        return;// ww w .j a  v  a 2s.c  o  m
    }

    float temperature = Float.MIN_VALUE;
    // According to Eltako Profile, temperature = -20C..60C, DB1 = 0..250, linear
    temperature = ((float) (dataBytes[1] & 0xff) * temperatureMultiplier) + temperatureLowerRange;

    // Generate a Temperature event.
    events.add(new TemperatureEvent(itemUID, temperature, data.getDate()));

    float relativeHumidity = Float.MIN_VALUE;
    // According to Enocean Equipment Profile, relativeHumidity = 0..100%, DB2 = 0..250, linear
    relativeHumidity = (float) (dataBytes[2] & 0xff) * relativeHumidityMultiplier;

    // Generate and send an relative humidity event.
    events.add(new RelativeHumidityEvent(itemUID, relativeHumidity, data.getDate()));

    float supplyVoltage = Float.MIN_VALUE;
    // According to Enocean Equipment Profile, relativeHumidity = 0..100%, DB2 = 0..250, linear
    supplyVoltage = (((float) (dataBytes[3] & 0xff) - 0x59) * supplyVoltageMultiplier)
            + supplyVoltageLowerRange;

    // Generate and send an relative humidity event.
    events.add(new RelativeHumidityEvent(itemUID, relativeHumidity, data.getDate()));

    // Remembering received data
    sensorData = new EEP070402DataImpl(supplyVoltage, temperature, relativeHumidity, data.getDate());

    // And then, send all generated events. Sending MUST be done after remembering received data, otherwise if an event listener performs
    // a getLastKnownData() on event reception, it might obtain non up-to-date data.
    eventGate.postEvents(events);
}

From source file:org.bitpipeline.lib.friendlyjson.JSONEntityTest.java

@Test
public void testJSonSerialization() throws JSONMappingException, JSONException {
    Entity orig = createEntity();

    JSONObject json = orig.toJson();//from w  ww . j a va2  s. c om
    assertNotNull(json);
    Entity copy = new Entity(json);

    assertNotNull(copy);
    assertEquals(orig.aBoolean, copy.aBoolean);
    assertEquals(orig.aByte, copy.aByte);
    assertEquals(orig.aChar, copy.aChar);
    assertEquals(orig.aShort, copy.aShort);
    assertEquals(orig.aInt, copy.aInt);
    assertEquals(orig.aLong, copy.aLong);
    assertEquals(orig.aFloat, copy.aFloat, Float.MIN_VALUE * 10.0f);
    assertEquals(orig.aDouble, copy.aDouble, Double.MIN_VALUE * 10.0);
    assertEquals(orig.aString, copy.aString);

    assertFalse(orig.transientValue == copy.transientValue);

    assertNotNull(copy.aMap);
    for (String key : orig.aMap.keySet()) {
        assertEquals(orig.aMap.get(key), copy.aMap.get(key));
    }

    assertNotNull(copy.aMapOfLists);
    for (String key : orig.aMapOfLists.keySet()) {
        assertEquals(orig.aMapOfLists.get(key), copy.aMapOfLists.get(key));
    }

    assertNotNull(copy.xptos);
    assertEquals(copy.xptos.size(), orig.xptos.size());
    for (Xpto x : orig.xptos) {
        boolean found = false;
        for (Xpto y : copy.xptos)
            if (x.getName().equals(y.getName()))
                found = true;
        assertTrue(found);
    }

    assertEquals(orig.toString(), copy.toString());
}

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

/**
 *
 * @param point//  w w  w .j  a  v a 2  s.  c om
 * @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:org.apache.orc.tools.json.JsonSchemaFinder.java

static HiveType pickType(JsonElement json) {
    if (json.isJsonPrimitive()) {
        JsonPrimitive prim = (JsonPrimitive) json;
        if (prim.isBoolean()) {
            return new BooleanType();
        } else if (prim.isNumber()) {
            Matcher matcher = DECIMAL_PATTERN.matcher(prim.getAsString());
            if (matcher.matches()) {
                int intDigits = matcher.group("int").length();
                String fraction = matcher.group("fraction");
                int scale = fraction == null ? 0 : fraction.length();
                if (scale == 0) {
                    if (intDigits < 19) {
                        long value = prim.getAsLong();
                        if (value >= -128 && value < 128) {
                            return new NumericType(HiveType.Kind.BYTE, intDigits, scale);
                        } else if (value >= -32768 && value < 32768) {
                            return new NumericType(HiveType.Kind.SHORT, intDigits, scale);
                        } else if (value >= -2147483648 && value < 2147483648L) {
                            return new NumericType(HiveType.Kind.INT, intDigits, scale);
                        } else {
                            return new NumericType(HiveType.Kind.LONG, intDigits, scale);
                        }/*from   w  w  w.  j a  va2  s. c  o  m*/
                    } else if (intDigits == 19) {
                        // at 19 digits, it may fit inside a long, but we need to check
                        BigInteger val = prim.getAsBigInteger();
                        if (val.compareTo(MIN_LONG) >= 0 && val.compareTo(MAX_LONG) <= 0) {
                            return new NumericType(HiveType.Kind.LONG, intDigits, scale);
                        }
                    }
                }
                if (intDigits + scale <= MAX_DECIMAL_DIGITS) {
                    return new NumericType(HiveType.Kind.DECIMAL, intDigits, scale);
                }
            }
            double value = prim.getAsDouble();
            if (value >= Float.MIN_VALUE && value <= Float.MAX_VALUE) {
                return new NumericType(HiveType.Kind.FLOAT, 0, 0);
            } else {
                return new NumericType(HiveType.Kind.DOUBLE, 0, 0);
            }
        } else {
            String str = prim.getAsString();
            if (TIMESTAMP_PATTERN.matcher(str).matches()) {
                return new StringType(HiveType.Kind.TIMESTAMP);
            } else if (HEX_PATTERN.matcher(str).matches()) {
                return new StringType(HiveType.Kind.BINARY);
            } else {
                return new StringType(HiveType.Kind.STRING);
            }
        }
    } else if (json.isJsonNull()) {
        return new NullType();
    } else if (json.isJsonArray()) {
        ListType result = new ListType();
        result.elementType = new NullType();
        for (JsonElement child : ((JsonArray) json)) {
            HiveType sub = pickType(child);
            if (result.elementType.subsumes(sub)) {
                result.elementType.merge(sub);
            } else if (sub.subsumes(result.elementType)) {
                sub.merge(result.elementType);
                result.elementType = sub;
            } else {
                result.elementType = new UnionType(result.elementType, sub);
            }
        }
        return result;
    } else {
        JsonObject obj = (JsonObject) json;
        StructType result = new StructType();
        for (Map.Entry<String, JsonElement> field : obj.entrySet()) {
            String fieldName = field.getKey();
            HiveType type = pickType(field.getValue());
            result.fields.put(fieldName, type);
        }
        return result;
    }
}

From source file:com.appsimobile.appsii.module.weather.loader.WeatherDataParser.java

@Nullable
private static WeatherData parseWeatherData(String woeid, SimpleDateFormat simpleDateFormat,
        JSONObject weatherJsonObj) throws ResponseParserException, JSONException, ParseException {
    SimpleJson weatherJson = new SimpleJson(weatherJsonObj);
    String city = weatherJson.optString("location.city");

    if (city == null) {
        String country = weatherJson.optString("location.country");
        String region = weatherJson.optString("location.region");
        if (country != null && region != null) {
            city = TextUtils.join(", ", new String[] { country, region });
        } else if (country != null) {
            city = country;// www.  java  2 s.  c om
        }
    }

    if (city == null) {
        Log.w("WeatherDataParser", "Error in weather-query. Ignoring location");
        return null;
    }

    WeatherData weatherData = new WeatherData();

    weatherData.location = city;

    weatherData.windChill = weatherJson.getInt("wind.chill", Integer.MIN_VALUE);
    weatherData.windDirection = weatherJson.getInt("wind.direction", Integer.MIN_VALUE);
    weatherData.windSpeed = (float) weatherJson.getDouble("wind.speed", Float.MIN_VALUE);

    weatherData.atmosphereHumidity = weatherJson.getInt("atmosphere.humidity", Integer.MIN_VALUE);
    weatherData.atmospherePressure = (float) weatherJson.getDouble("atmosphere.pressure", Float.MIN_VALUE);
    weatherData.atmosphereRising = weatherJson.getInt("atmosphere.rising", Integer.MIN_VALUE);
    weatherData.atmosphereVisible = (float) weatherJson.getDouble("atmosphere.visibility", Float.MIN_VALUE);

    weatherData.sunrise = weatherJson.optString("astronomy.sunrise");
    weatherData.sunset = weatherJson.optString("astronomy.sunset");

    weatherData.nowConditionCode = weatherJson.getInt("item.condition.code", WeatherData.INVALID_CONDITION);
    weatherData.nowConditionText = weatherJson.optString("item.condition.text");
    weatherData.nowTemperature = weatherJson.getInt("item.condition.temp", WeatherData.INVALID_TEMPERATURE);

    JSONArray forecastArray = weatherJson.optJsonArray("item.forecast");

    if (forecastArray != null) {

        int fl = forecastArray.length();
        for (int k = 0; k < fl; k++) {
            JSONObject forecastJson = forecastArray.getJSONObject(k);
            WeatherData.Forecast forecast = new WeatherData.Forecast();

            String date = forecastJson.optString("date");
            long millis = simpleDateFormat.parse(date).getTime();

            forecast.julianDay = Time.getJulianDay(millis, 0);
            forecast.conditionCode = forecastJson.optInt("code", WeatherData.INVALID_CONDITION);
            forecast.forecastText = forecastJson.optString("text");
            forecast.low = forecastJson.optInt("low", WeatherData.INVALID_TEMPERATURE);
            forecast.high = forecastJson.optInt("high", WeatherData.INVALID_TEMPERATURE);

            weatherData.forecasts.add(forecast);
        }

    }
    weatherData.woeid = woeid;
    return weatherData;
}

From source file:org.apache.hadoop.hive.accumulo.AccumuloTestSetup.java

protected void createAccumuloTable(Connector conn)
        throws TableExistsException, TableNotFoundException, AccumuloException, AccumuloSecurityException {
    TableOperations tops = conn.tableOperations();
    if (tops.exists(TABLE_NAME)) {
        tops.delete(TABLE_NAME);/* w w w .j  a  va  2  s.c  o  m*/
    }

    tops.create(TABLE_NAME);

    boolean[] booleans = new boolean[] { true, false, true };
    byte[] bytes = new byte[] { Byte.MIN_VALUE, -1, Byte.MAX_VALUE };
    short[] shorts = new short[] { Short.MIN_VALUE, -1, Short.MAX_VALUE };
    int[] ints = new int[] { Integer.MIN_VALUE, -1, Integer.MAX_VALUE };
    long[] longs = new long[] { Long.MIN_VALUE, -1, Long.MAX_VALUE };
    String[] strings = new String[] { "Hadoop, Accumulo", "Hive", "Test Strings" };
    float[] floats = new float[] { Float.MIN_VALUE, -1.0F, Float.MAX_VALUE };
    double[] doubles = new double[] { Double.MIN_VALUE, -1.0, Double.MAX_VALUE };
    HiveDecimal[] decimals = new HiveDecimal[] { HiveDecimal.create("3.14159"), HiveDecimal.create("2.71828"),
            HiveDecimal.create("0.57721") };
    Date[] dates = new Date[] { Date.valueOf("2014-01-01"), Date.valueOf("2014-03-01"),
            Date.valueOf("2014-05-01") };
    Timestamp[] timestamps = new Timestamp[] { new Timestamp(50), new Timestamp(100), new Timestamp(150) };

    BatchWriter bw = conn.createBatchWriter(TABLE_NAME, new BatchWriterConfig());
    final String cf = "cf";
    try {
        for (int i = 0; i < 3; i++) {
            Mutation m = new Mutation("key-" + i);
            m.put(cf, "cq-boolean", Boolean.toString(booleans[i]));
            m.put(cf.getBytes(), "cq-byte".getBytes(), new byte[] { bytes[i] });
            m.put(cf, "cq-short", Short.toString(shorts[i]));
            m.put(cf, "cq-int", Integer.toString(ints[i]));
            m.put(cf, "cq-long", Long.toString(longs[i]));
            m.put(cf, "cq-string", strings[i]);
            m.put(cf, "cq-float", Float.toString(floats[i]));
            m.put(cf, "cq-double", Double.toString(doubles[i]));
            m.put(cf, "cq-decimal", decimals[i].toString());
            m.put(cf, "cq-date", dates[i].toString());
            m.put(cf, "cq-timestamp", timestamps[i].toString());

            bw.addMutation(m);
        }
    } finally {
        bw.close();
    }
}

From source file:fi.hut.soberit.accelerometer.AccelerometerAxisUploader.java

@Override
public void onReceiveObservations(List<Parcelable> observations) {
    float maxX = Float.MIN_VALUE;

    float maxY = Float.MIN_VALUE;
    float maxZ = Float.MIN_VALUE;

    for (Parcelable parcelable : observations) {
        GenericObservation observation = (GenericObservation) parcelable;

        float x = observation.getFloat(0);
        float y = observation.getFloat(4);
        float z = observation.getFloat(8);

        if (x > maxX) {
            maxX = x;//from ww w  .j  a  va  2s. c  o m
        }
        if (y > maxY) {
            maxY = y;
        }
        if (z > maxZ) {
            maxZ = z;
        }
    }

    recordsForUpload.add(new UploadableRecord(System.currentTimeMillis(), maxX, maxY, maxZ));
}

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

@Override
public JSONObject toJSON() {
    JSONObject res = new JSONObject();
    JSONObject o = null;/*from w  ww. j a v  a  2  s. c o  m*/

    try {
        if (date == null) {
            res.put("noDataAvailable", true);
            return res;
        }

        long timestamp = date.getTime();

        if (temperature != Float.MIN_VALUE) {
            o = new JSONObject();
            o.put(JSONValueField.value.name(), temperature);
            o.put(JSONValueField.uiValue.name(), df.format(temperature));
            o.put(JSONValueField.unit.name(), " &deg;C");
            o.put(JSONValueField.timestamp.name(), timestamp);
            res.put("temperature", o);
        }

        o = new JSONObject();
        o.put(JSONValueField.value.name(), relativeHumidity);
        o.put(JSONValueField.uiValue.name(), df.format(relativeHumidity));
        o.put(JSONValueField.unit.name(), "%");
        o.put(JSONValueField.timestamp.name(), timestamp);
        res.put("relativeHumidity", o);
    } catch (JSONException e) {
        Logger.error(LC.gi(), this,
                "toJSON(): An exception while building a JSON view of a EnoceanData SHOULD never happen. Check the code !",
                e);
        return null;
    }

    return res;
}

From source file:MSUmpire.DIA.MixtureModelKDESemiParametric.java

public void GeneratePlot(String pngfile) throws IOException {
    String modelfile = FilenameUtils.getFullPath(pngfile) + "/" + FilenameUtils.getBaseName(pngfile)
            + "_ModelPoints.txt";
    FileWriter writer = new FileWriter(modelfile);

    double[] IDObs = new double[IDEmpiricalDist.getN()];
    double[] DecoyObs = new double[DecoyEmpiricalDist.getN()];

    for (int i = 0; i < IDEmpiricalDist.getN(); i++) {
        IDObs[i] = IDEmpiricalDist.getObs(i);
    }//from  ww w. j  a va2s  .c om
    for (int i = 0; i < DecoyEmpiricalDist.getN(); i++) {
        DecoyObs[i] = DecoyEmpiricalDist.getObs(i);
    }

    XYSeries model1 = new XYSeries("Incorrect matches");
    XYSeries model2 = new XYSeries("Correct matches");
    XYSeries model3 = new XYSeries("All target hits");

    writer.write("UScore\tModel\tCorrect\tDecoy\n");
    for (int i = 0; i < NoBinPoints; i++) {
        model1.add(model_kde_x[i], decoy_kde_y[i]);
        model2.add(model_kde_x[i], correct_kde_y[i]);
        model3.add(model_kde_x[i], model_kde_y[i]);
        writer.write(model_kde_x[i] + "\t" + model_kde_y[i] + "\t" + correct_kde_y[i] + "\t" + decoy_kde_y[i]
                + "\n");
    }
    writer.close();

    MixtureModelProb = new float[NoBinPoints + 1][3];
    float positiveaccu = 0f;
    float negativeaccu = 0f;

    MixtureModelProb[0][0] = (float) model2.getMaxX() + Float.MIN_VALUE;
    MixtureModelProb[0][1] = 1f;
    MixtureModelProb[0][2] = 1f;

    for (int i = 1; i < NoBinPoints + 1; i++) {
        double positiveNumber = correct_kde_y[NoBinPoints - i];
        double negativeNumber = decoy_kde_y[NoBinPoints - i];
        MixtureModelProb[i][0] = (float) model_kde_x[NoBinPoints - i];
        positiveaccu += positiveNumber;
        negativeaccu += negativeNumber;
        MixtureModelProb[i][2] = 0.999999f * (float) (positiveNumber / (negativeNumber + positiveNumber));
        MixtureModelProb[i][1] = 0.999999f * (float) (positiveaccu / (negativeaccu + positiveaccu));
    }

    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(model1);
    dataset.addSeries(model2);
    dataset.addSeries(model3);

    HistogramDataset histogramDataset = new HistogramDataset();
    histogramDataset.setType(HistogramType.SCALE_AREA_TO_1);
    histogramDataset.addSeries("ID hits", IDObs, 100);
    histogramDataset.addSeries("Decoy hits", DecoyObs, 100);
    //histogramDataset.addSeries("Model hits", ModelObs, 100);

    JFreeChart chart = ChartFactory.createHistogram(FilenameUtils.getBaseName(pngfile), "Score", "Hits",
            histogramDataset, PlotOrientation.VERTICAL, true, false, false);
    XYPlot plot = chart.getXYPlot();

    NumberAxis domain = (NumberAxis) plot.getDomainAxis();
    domain.setRange(min, max);
    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    plot.setForegroundAlpha(0.8f);
    chart.setBackgroundPaint(Color.white);

    XYLineAndShapeRenderer render = new XYLineAndShapeRenderer();

    plot.setDataset(1, dataset);
    plot.setRenderer(1, render);
    plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);
    try {
        ChartUtilities.saveChartAsPNG(new File(pngfile), chart, 1000, 600);
    } catch (IOException e) {
    }
}