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:com.eventsourcing.postgresql.PostgreSQLJournalTest.java

@Test
@SneakyThrows//from   ww  w  .j  a  v  a 2  s.c  o m
public void serializationValue() {
    assertEquals(serializationResult(TestClass.builder().pByte(Byte.MIN_VALUE).build()).pByte(),
            Byte.MIN_VALUE);
    assertEquals(serializationResult(TestClass.builder().pByte(Byte.MAX_VALUE).build()).pByte(),
            Byte.MAX_VALUE);

    assertEquals((byte) serializationResult(TestClass.builder().oByte(Byte.MIN_VALUE).build()).oByte(),
            Byte.MIN_VALUE);
    assertEquals((byte) serializationResult(TestClass.builder().oByte(Byte.MAX_VALUE).build()).oByte(),
            Byte.MAX_VALUE);

    assertEquals(
            serializationResult(TestClass.builder().pByteArr("Hello, world".getBytes()).build()).pByteArr(),
            "Hello, world".getBytes());
    assertEquals(
            serializationResult(TestClass.builder().oByteArr(toObject(("Hello, world").getBytes())).build())
                    .oByteArr(),
            "Hello, world".getBytes());

    assertEquals(serializationResult(TestClass.builder().pShort(Short.MIN_VALUE).build()).pShort(),
            Short.MIN_VALUE);
    assertEquals((short) serializationResult(TestClass.builder().oShort(Short.MAX_VALUE).build()).oShort(),
            Short.MAX_VALUE);

    assertEquals(serializationResult(TestClass.builder().pInt(Integer.MIN_VALUE).build()).pInt(),
            Integer.MIN_VALUE);
    assertEquals((int) serializationResult(TestClass.builder().oInt(Integer.MAX_VALUE).build()).oInt(),
            Integer.MAX_VALUE);

    assertEquals(serializationResult(TestClass.builder().pLong(Long.MIN_VALUE).build()).pLong(),
            Long.MIN_VALUE);
    assertEquals((long) serializationResult(TestClass.builder().oLong(Long.MAX_VALUE).build()).oLong(),
            Long.MAX_VALUE);

    assertEquals(serializationResult(TestClass.builder().pFloat(Float.MIN_VALUE).build()).pFloat(),
            Float.MIN_VALUE);
    assertEquals(serializationResult(TestClass.builder().oFloat(Float.MAX_VALUE).build()).oFloat(),
            Float.MAX_VALUE);

    assertEquals(serializationResult(TestClass.builder().pDouble(Double.MIN_VALUE).build()).pDouble(),
            Double.MIN_VALUE);
    assertEquals(serializationResult(TestClass.builder().oDouble(Double.MAX_VALUE).build()).oDouble(),
            Double.MAX_VALUE);

    assertEquals(serializationResult(TestClass.builder().pBoolean(true).build()).pBoolean(), true);
    assertEquals(serializationResult(TestClass.builder().pBoolean(false).build()).pBoolean(), false);

    assertEquals((boolean) serializationResult(TestClass.builder().oBoolean(true).build()).oBoolean(), true);
    assertEquals((boolean) serializationResult(TestClass.builder().oBoolean(false).build()).oBoolean(), false);

    assertEquals(serializationResult(TestClass.builder().str("Hello, world").build()).str(), "Hello, world");

    UUID uuid = UUID.randomUUID();
    assertEquals(serializationResult(TestClass.builder().uuid(uuid).build()).uuid(), uuid);

    assertEquals(serializationResult(TestClass.builder().e(TestClass.E.B).build()).e(), TestClass.E.B);

    assertEquals(serializationResult(TestClass.builder().value(new SomeValue("test")).build()).value().value(),
            "test");

    assertEquals(serializationResult(TestClass.builder()
            .value1(new SomeValue1(Collections.singletonList(new SomeValue2(new SomeValue("test"))))).build())
                    .value1().value().get(0).value().value(),
            "test");

    ArrayList<List<String>> l = new ArrayList<>();
    ArrayList<String> l1 = new ArrayList<>();
    l1.add("test");
    l.add(l1);
    assertEquals(serializationResult(TestClass.builder().list(l).build()).list().get(0).get(0), "test");

    Map<String, List<String>> map = new HashMap<>();
    LinkedList<String> list = new LinkedList<>(Arrays.asList("Hello"));
    map.put("test", list);
    map.put("anothertest", list);
    assertEquals(serializationResult(TestClass.builder().map(map).build()).map().get("test").get(0), "Hello");
    assertEquals(serializationResult(TestClass.builder().map(map).build()).map().get("anothertest").get(0),
            "Hello");

    assertFalse(
            serializationResult(TestClass.builder().optional(Optional.empty()).build()).optional().isPresent());
    assertTrue(serializationResult(TestClass.builder().optional(Optional.of("test")).build()).optional()
            .isPresent());
    assertEquals(
            serializationResult(TestClass.builder().optional(Optional.of("test")).build()).optional().get(),
            "test");

    BigDecimal bigDecimal = new BigDecimal("0.00000000000000000000000000001");
    assertEquals(serializationResult(TestClass.builder().bigDecimal(bigDecimal).build()).bigDecimal(),
            bigDecimal);

    BigInteger bigInteger = new BigInteger("100001");
    assertEquals(serializationResult(TestClass.builder().bigInteger(bigInteger).build()).bigInteger(),
            bigInteger);

    Date date = new Date();
    assertEquals(serializationResult(TestClass.builder().date(date).build()).date(), date);
}

From source file:org.apache.flink.table.codegen.SortCodeGeneratorTest.java

private Object value1(InternalType type, Random rnd) {
    if (type.equals(InternalTypes.BOOLEAN)) {
        return false;
    } else if (type.equals(InternalTypes.BYTE)) {
        return Byte.MIN_VALUE;
    } else if (type.equals(InternalTypes.SHORT)) {
        return Short.MIN_VALUE;
    } else if (type.equals(InternalTypes.INT)) {
        return Integer.MIN_VALUE;
    } else if (type.equals(InternalTypes.LONG)) {
        return Long.MIN_VALUE;
    } else if (type.equals(InternalTypes.FLOAT)) {
        return Float.MIN_VALUE;
    } else if (type.equals(InternalTypes.DOUBLE)) {
        return Double.MIN_VALUE;
    } else if (type.equals(InternalTypes.STRING)) {
        return BinaryString.fromString("");
    } else if (type instanceof DecimalType) {
        DecimalType decimalType = (DecimalType) type;
        return Decimal.fromBigDecimal(new BigDecimal(Integer.MIN_VALUE), decimalType.precision(),
                decimalType.scale());/*  w w w.  java2s .c o  m*/
    } else if (type instanceof ArrayType) {
        byte[] bytes = new byte[rnd.nextInt(7) + 1];
        rnd.nextBytes(bytes);
        BinaryArray array = BinaryArray.fromPrimitiveArray(bytes);
        for (int i = 0; i < bytes.length; i++) {
            array.setNullByte(i);
        }
        return array;
    } else if (type.equals(InternalTypes.BINARY)) {
        byte[] bytes = new byte[rnd.nextInt(7) + 1];
        rnd.nextBytes(bytes);
        return bytes;
    } else if (type instanceof RowType) {
        return GenericRow.of(new Object[] { null });
    } else if (type instanceof GenericType) {
        return new BinaryGeneric<>(rnd.nextInt(), IntSerializer.INSTANCE);
    } else {
        throw new RuntimeException("Not support!");
    }
}

From source file:org.apache.parquet.filter2.dictionarylevel.DictionaryFilterTest.java

@Test
public void testGtFloat() throws Exception {
    FloatColumn f = floatColumn("float_field");
    float highest = Float.MIN_VALUE;
    for (int value : intValues) {
        highest = Math.max(highest, toFloat(value));
    }//from ww w  .  jav  a 2s. co  m

    assertTrue("Should drop: > highest value", canDrop(gt(f, highest), ccmd, dictionaries));
    assertFalse("Should not drop: > (highest value - 1.0)", canDrop(gt(f, highest - 1.0f), ccmd, dictionaries));

    assertFalse("Should not drop: contains matching values",
            canDrop(gt(f, Float.MIN_VALUE), ccmd, dictionaries));
}

From source file:org.gradoop.flink.datagen.transactions.foodbroker.config.FoodBrokerConfig.java

/**
 * Loads the maximal price of a product.
 *
 * @return float value of the max price/*from  w w  w. j  av a  2 s .c  o  m*/
 */
public Float getProductMaxPrice() {
    Float maxPrice = Float.MIN_VALUE;

    try {
        maxPrice = (float) getMasterDataConfigNode("Product").getDouble("maxPrice");
    } catch (JSONException e) {
        e.printStackTrace();
    }
    return maxPrice;
}

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

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

    try {
        if (switchDates[0] == null && switchDates[1] == null && valueDate == null) {
            res.put("noDataAvailable", true);
            return res;
        }

        switch (EEPType) {
        case 0x0:
        case 0x6:
            o = new JSONObject();
            o.put(JSONValueField.value.name(), switchStates[0].name());
            o.put(JSONValueField.uiValue.name(), switchStates[0].name());
            o.put(JSONValueField.timestamp.name(), switchDates[0].getTime());
            res.put("switchState", o);
            break;
        case 0x2:
            o = new JSONObject();
            o.put(JSONValueField.value.name(), dimmerValue);
            o.put(JSONValueField.uiValue.name(), dimmerValue);
            o.put(JSONValueField.timestamp.name(), switchDates[0].getTime());
            o.put(JSONValueField.unit.name(), " %");
            res.put("dimmerValue", o);
            break;
        case 0x11:
            o = new JSONObject();
            o.put(JSONValueField.value.name(), switchStates[0].name());
            o.put(JSONValueField.uiValue.name(), switchStates[0].name());
            if (switchDates[0] != null) {
                o.put(JSONValueField.timestamp.name(), switchDates[0].getTime());
            }
            res.put("channel_1", o);

            o = new JSONObject();
            o.put(JSONValueField.value.name(), switchStates[1].name());
            o.put(JSONValueField.uiValue.name(), switchStates[1].name());
            if (switchDates[1] != null) {
                o.put(JSONValueField.timestamp.name(), switchDates[1].getTime());
            }
            res.put("channel_2", o);

            o = new JSONObject();
            o.put(JSONValueField.value.name(), mode.name());
            o.put(JSONValueField.uiValue.name(), mode.name());
            res.put("mode", o);
            break;
        }

        if (value != Float.MIN_VALUE && unit != MeasurementUnit.UNKNOWN) {
            o = new JSONObject();
            o.put(JSONValueField.value.name(), value);
            o.put(JSONValueField.uiValue.name(), value);
            o.put(JSONValueField.unit.name(), toText(unit));
            o.put(JSONValueField.timestamp.name(), valueDate.getTime());
            res.put("energyValue", 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:com.epam.catgenome.entity.vcf.VcfFilterForm.java

private void tryAddFloatingKeyFalueFilter(BooleanQuery.Builder builder, Map.Entry<String, Object> entry,
        String key, List list, Object val) {
    if (val instanceof Float || entry.getValue() instanceof Double) {
        builder.add(FloatPoint.newRangeQuery(key, list.get(0) != null ? (Float) list.get(0) : Float.MIN_VALUE,
                list.get(1) != null ? (Float) list.get(1) : Float.MAX_VALUE), BooleanClause.Occur.MUST);
    }//from w  w  w.  ja  v a 2  s.co  m
}

From source file:org.kaaproject.kaa.demo.powerplant.fragment.DashboardFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final View rootView = inflater.inflate(R.layout.fragment_dashboard, container, false);

    androidKaaPlatformContext = new AndroidKaaPlatformContext(getActivity());
    kaaClient = Kaa.newClient(androidKaaPlatformContext);

    endpoint = DataEndpointFactory.createEndpoint(kaaClient.getConfiguration(), getActivity());
    Log.i(TAG, "Default configuration: " + kaaClient.getConfiguration().toString());

    kaaClient.addConfigurationListener(new ConfigurationListener() {
        @Override/*from   w ww.ja v a2 s . co m*/
        public void onConfigurationUpdate(PowerPlantEndpointConfiguration config) {
            endpoint.stop();
            endpoint = DataEndpointFactory.createEndpoint(config, getActivity());
            Log.i(TAG, "Updating configuration: " + config.toString());
        }
    });

    kaaClient.start();

    gaugeCharts.add((GaugeChart) rootView.findViewById(R.id.gaugeChart11));
    gaugeCharts.add((GaugeChart) rootView.findViewById(R.id.gaugeChart12));
    gaugeCharts.add((GaugeChart) rootView.findViewById(R.id.gaugeChart13));
    gaugeCharts.add((GaugeChart) rootView.findViewById(R.id.gaugeChart21));
    gaugeCharts.add((GaugeChart) rootView.findViewById(R.id.gaugeChart22));
    gaugeCharts.add((GaugeChart) rootView.findViewById(R.id.gaugeChart23));
    logBox = (TextView) rootView.findViewById(R.id.logBox);
    logBox.setMovementMethod(new ScrollingMovementMethod());

    updateThread = new Thread(new Runnable() {

        @Override
        public void run() {

            Log.i(TAG, "generating history data ");

            final List<DataReport> reports = endpoint.getHistoryData(0);
            if (reports == null) {
                mActivity.runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        Toast.makeText(mActivity, "No Data!", Toast.LENGTH_LONG).show();
                        try {
                            Thread.sleep(3000);
                        } catch (InterruptedException e) {
                        }
                        mActivity.finish();
                    }
                });
            } else {
                mActivity.runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        Log.i(TAG, "populating charts with data " + reports.size());
                        prepareLineChart(rootView, reports);
                        Log.i(TAG, "populated line chart with data ");
                        if (!reports.isEmpty()) {
                            preparePieChart(rootView, reports.get(reports.size() - 1));
                        } else {
                            preparePieChart(rootView, INITIAL_REPORT);
                        }
                        Log.i(TAG, "populated pie chart with data ");
                    }
                });

                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e1) {
                    e1.printStackTrace();
                }

                DataReport previousReport = INITIAL_REPORT;
                long previousUpdate = 0l;
                while (true) {
                    try {
                        Thread.sleep(UPDATE_CHECK_PERIOD);
                        long updateDelta = System.currentTimeMillis() - previousUpdate;
                        if (updateDelta < UPDATE_PERIOD) {
                            continue;
                        } else {
                            Log.i(TAG, "Updating since -" + (updateDelta / 1000.) + " s.");
                        }
                        DataReport latestDataCandidate = endpoint.getLatestData();
                        latestDataCandidate = (latestDataCandidate == null ? previousReport
                                : latestDataCandidate);
                        Log.i(TAG, "Latest data: " + latestDataCandidate.toString());
                        Log.i(TAG, "Previous data: " + previousReport.toString());
                        previousReport = latestDataCandidate;
                        previousUpdate = System.currentTimeMillis();
                    } catch (InterruptedException e) {
                        Log.e(TAG, "Failed to fetch data", e);
                    }

                    final DataReport latestData = previousReport;
                    Log.i(TAG, "latest data: " + latestData.toString());

                    mActivity.runOnUiThread(new Runnable() {

                        @Override
                        public void run() {
                            float maxValue = Float.MIN_VALUE;
                            float minValue = Float.MAX_VALUE;

                            PieChartData data = pieChart.getPieChartData();
                            float plantVoltage = 0.0f;

                            int counter = 0;
                            for (DataPoint dp : latestData.getDataPoints()) {
                                float curVoltage = convertVoltage(dp.getVoltage());
                                plantVoltage += curVoltage;
                                SliceValue sliceValue = data.getValues().get(dp.getPanelId());
                                sliceValue.setTarget(curVoltage);
                                gaugeCharts.get(counter).setValue(dp.getAverageVoltage());
                                showLogIfNeeded(counter, curVoltage * 1000);
                                counter++;
                                Log.i(TAG, dp.toString());
                            }

                            float gridVoltage = (latestData.getPowerConsumption() - plantVoltage * 1000) / 1000;
                            pieChart.startDataAnimation(UPDATE_PERIOD / 2);
                            updateLabels(plantVoltage * 1000, gridVoltage);

                            // Actual point update
                            int curPointIndex = line.getValues().size() - FUTURE_POINTS_COUNT;
                            PointValue curPoint = line.getValues().get(curPointIndex);
                            curPoint.set(curPoint.getX(), plantVoltage);
                            for (PointValue point : line.getValues()) {
                                point.setTarget(point.getX() - 1, point.getY());
                                minValue = Math.min(minValue, point.getY());
                                maxValue = Math.max(maxValue, point.getY());
                            }
                            if (line.getValues()
                                    .size() == (POINTS_COUNT + PAST_POINTS_COUNT + FUTURE_POINTS_COUNT)) {
                                line.getValues().remove(0);
                            }
                            // Adding one dot to the end;
                            line.getValues()
                                    .add(new PointValue(POINTS_COUNT + FUTURE_POINTS_COUNT, plantVoltage));

                            lineChart.startDataAnimation(UPDATE_PERIOD / 2);

                            lineChart.getChartRenderer().setMinViewportYValue(MIN_VOLTAGE);
                            lineChart.getChartRenderer().setMaxViewportYValue(
                                    (MAX_VOLTAGE * MAX_PANEL_PER_ZONE * NUM_ZONES) / 1000);
                        }
                    });
                }
            }
        }
    });

    updateThread.start();

    return rootView;
}

From source file:com.davidmiguel.gobees.recording.RecordingFragment.java

/**
 * Configure temperature chart and the data.
 *
 * @param meteo meteo records./*  w w w .j  a va  2 s .c  o  m*/
 */
private void setupTempChart(List<MeteoRecord> meteo) {
    // Setup data
    List<Entry> entries = new ArrayList<>();
    // Add as first entry a copy of the first temperature record
    // First relative timestamp is 0
    entries.add(new Entry(0, (float) meteo.get(0).getTemperature()));
    // Add all temperature records
    float maxTemp = Float.MIN_VALUE;
    float minTemp = Float.MAX_VALUE;
    for (MeteoRecord meteoRecord : meteo) {
        // Convert timestamp to seconds and relative to first timestamp
        long timestamp = meteoRecord.getTimestamp().getTime() / 1000 - referenceTimestamp;
        float temperature = (float) meteoRecord.getTemperature();
        entries.add(new Entry(timestamp, temperature));
        // Get max and min temperature
        if (temperature > maxTemp) {
            maxTemp = temperature;
        }
        if (temperature < minTemp) {
            minTemp = temperature;
        }
    }
    // Add as last entry a copy of the last temperature record
    entries.add(new Entry(lastTimestamp, (float) meteo.get(meteo.size() - 1).getTemperature()));
    // Style char lines (type, color, etc.)
    TempValueFormatter tempValueFormatter = new TempValueFormatter(
            GoBeesPreferences.isMetric(getContext()) ? TempValueFormatter.Unit.CELSIUS
                    : TempValueFormatter.Unit.FAHRENHEIT);
    tempChart.setData(
            new LineData(configureWeatherChart(tempChart, R.string.temperature, R.color.colorLineTempChart,
                    R.color.colorFillTempChart, entries, tempValueFormatter, minTemp - 5, maxTemp + 5)));
}

From source file:org.las.tools.LanguageIdentifier.LanguageIdentifier.java

/**
 * Identify language of a content./*www . ja va2s.  c  o  m*/
 * 
 * @param content is the content to analyze.
 * @return The 2 letter
 *         <a href="http://www.w3.org/WAI/ER/IG/ert/iso639.htm">ISO 639
 *         language code</a> (en, fi, sv, ...) of the language that best
 *         matches the specified content.
 */
public String identify(StringBuilder content) {

    // Identify is Latin or not
    if (!isLatinCharacter(content.toString())) {
        return "not-latin";
    }

    StringBuilder text = content;
    if ((analyzeLength > 0) && (content.length() > analyzeLength)) {
        text = new StringBuilder().append(content);
        text.setLength(analyzeLength);
    }

    suspect.analyze(text);
    Iterator<NGramEntry> iter = suspect.getSorted().iterator();
    float topscore = Float.MIN_VALUE;
    String lang = "";
    HashMap<NGramProfile, Float> scores = new HashMap<NGramProfile, Float>();
    NGramEntry searched = null;

    while (iter.hasNext()) {
        searched = iter.next();
        NGramEntry[] ngrams = ngramsIdx.get(searched.getSeq());
        if (ngrams != null) {
            for (int j = 0; j < ngrams.length; j++) {
                NGramProfile profile = ngrams[j].getProfile();
                Float pScore = scores.get(profile);
                if (pScore == null) {
                    pScore = new Float(0);
                }
                float plScore = pScore.floatValue();
                plScore += ngrams[j].getFrequency() + searched.getFrequency();
                scores.put(profile, new Float(plScore));
                if (plScore > topscore) {
                    topscore = plScore;
                    lang = profile.getName();
                }
            }
        }
    }
    return lang;
}

From source file:mase.stat.MasterTournament.java

private int bestIndex(List<EvaluationResult[]> evals, int subpop) {
    float best = Float.MIN_VALUE;
    int bestIndex = -1;
    for (int i = 0; i < evals.size(); i++) {
        EvaluationResult[] e = evals.get(i);
        float fit = (Float) (((CompoundEvaluationResult) e[0]).getEvaluation(subpop).value());
        if (fit > best) {
            best = fit;//from   w ww  .  j a v  a  2s  . com
            bestIndex = i;
        }
    }
    return bestIndex;
}