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.EEP0710xxDataImpl.java

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

    try {//from  ww  w  . ja v  a  2  s.  c o m
        float temperature = (float) lastKnownData.getDouble("temperature");
        float relativeHumidity = (float) lastKnownData.getDouble("relativeHumidity");
        FanSpeed fanSpeed = FanSpeed.valueOf(lastKnownData.getString("fanSpeed"));
        int setPoint = lastKnownData.getInt("setPoint");
        long LOPBDate = lastKnownData.optLong("LOPBDate");
        DayNightState dayNightState = DayNightState.valueOf(lastKnownData.getString("dayNightState"));
        ;
        Date date = new Date(lastKnownData.getLong("date"));

        return new EEP0710xxDataImpl(temperature, relativeHumidity, fanSpeed, setPoint,
                (LOPBDate == 0) ? null : new Date(LOPBDate), dayNightState, 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 EEP0710xxDataImpl(Float.MIN_VALUE, Float.MIN_VALUE, FanSpeed.UNKNOWN, -1, null,
                DayNightState.UNKNOWN, null);
    }
}

From source file:cz.cvut.kbss.jsonld.jackson.serialization.JacksonJsonWriterTest.java

@Test
public void writeNumberFloatWritesFloat() throws Exception {
    final Float number = Float.MIN_VALUE;
    writer.writeNumber(number);/*from   ww w. ja  v a  2  s. co  m*/
    verify(generator).writeNumber(number);
}

From source file:org.joda.primitives.collection.impl.AbstractTestFloatCollection.java

public Float[] getFullNonNullElements() {
    return 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) };
}

From source file:Main.java

/**
 * Returns the floating-point value adjacent to <code>f</code> in
 * the direction of negative infinity.  This method is
 * semantically equivalent to <code>nextAfter(f,
 * Float.NEGATIVE_INFINITY)</code>; however, a
 * <code>nextDown</code> implementation may run faster than its
 * equivalent <code>nextAfter</code> call.
 *
 * <p>Special Cases:/*from   w  w w. j av  a2s. c  o m*/
 * <ul>
 * <li> If the argument is NaN, the result is NaN.
 *
 * <li> If the argument is negative infinity, the result is
 * negative infinity.
 *
 * <li> If the argument is zero, the result is
 * <code>-Float.MIN_VALUE</code>
 *
 * </ul>
 *
 * @param f  starting floating-point value
 * @return The adjacent floating-point value closer to negative
 * infinity.
 * @author Joseph D. Darcy
 */
public static double nextDown(float f) {
    if (isNaN(f) || f == Float.NEGATIVE_INFINITY)
        return f;
    else {
        if (f == 0.0f)
            return -Float.MIN_VALUE;
        else
            return Float.intBitsToFloat(Float.floatToRawIntBits(f) + ((f > 0.0f) ? -1 : +1));
    }
}

From source file:org.apache.nifi.xml.inference.XmlSchemaInference.java

private DataType inferTextualDataType(final String text) {
    if (text == null || text.isEmpty()) {
        return null;
    }// www .  j  a va  2s . c om

    if (NumberUtils.isParsable(text)) {
        if (text.contains(".")) {
            try {
                final double doubleValue = Double.parseDouble(text);
                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(text);
            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 (text.equalsIgnoreCase("true") || text.equalsIgnoreCase("false")) {
        return RecordFieldType.BOOLEAN.getDataType();
    }

    final Optional<DataType> timeDataType = timeValueInference.getDataType(text);
    return timeDataType.orElse(RecordFieldType.STRING.getDataType());
}

From source file:com.example.programming.proximityalerts.ProximityAlertService.java

@Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        Location bestLocation = null;

        latitude = intent.getDoubleExtra(LATITUDE_INTENT_KEY, Double.MIN_VALUE);
        longitude = intent.getDoubleExtra(LONGITUDE_INTENT_KEY, Double.MIN_VALUE);
        radius = intent.getFloatExtra(RADIUS_INTENT_KEY, Float.MIN_VALUE);

        for (String provider : locationManager.getProviders(false)) {
            if (ActivityCompat.checkSelfPermission(this,
                    Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED
                    && ActivityCompat.checkSelfPermission(this,
                            Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
                // TODO: Consider calling
                //    ActivityCompat#requestPermissions
                // here to request the missing permissions, and then overriding
                //   public void onRequestPermissionsResult(int requestCode, String[] permissions,
                //                                          int[] grantResults)
                // to handle the case where the user grants the permission. See the documentation
                // for ActivityCompat#requestPermissions for more details.
                return TODO;
            }/*w ww  .  ja  v a 2 s .c  om*/
            Location location = locationManager.getLastKnownLocation(provider);

            if (bestLocation == null) {
                bestLocation = location;
            } else {
                if (location.getAccuracy() < bestLocation.getAccuracy()) {
                    bestLocation = location;
                }
            }
        }

        if (bestLocation != null) {
            if (getDistance(bestLocation) <= radius) {
                inProximity = true;
            } else {
                inProximity = false;
            }
        }

        locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, this);

        return START_STICKY;
    }

From source file:inflor.core.plots.HistogramPlot.java

@Override
public JFreeChart createChart(FCSFrame dataFrame, TransformSet transforms) {

    Optional<FCSDimension> domainDimension = FCSUtilities.findCompatibleDimension(dataFrame,
            spec.getDomainAxisName());//from   w w  w .j  av  a  2s.c  o  m

    AbstractTransform transform = transforms.get(domainDimension.get().getShortName());
    double[] transformedData = transform.transform(domainDimension.get().getData());

    Histogram1D hist = new Histogram1D(transformedData, transform.getMinTranformedValue(),
            transform.getMaxTransformedValue(), ChartingDefaults.BIN_COUNT);

    DefaultXYDataset dataset = new DefaultXYDataset();
    dataset.addSeries(dataFrame.getDisplayName(), hist.getData());

    ValueAxis domainAxis = PlotUtils.createAxis(domainDimension.get().getDisplayName(), transform);
    ValueAxis rangeAxis = new NumberAxis(spec.getRangeAxisName());
    FillType fillType = FillType.TO_ZERO;
    XYItemRenderer renderer = new XYSplineRenderer(1, fillType);
    renderer.setSeriesShape(0, ShapeUtilities.createDiamond(Float.MIN_VALUE));// Make the points
                                                                              // invisible
    XYPlot plot = new XYPlot(dataset, domainAxis, rangeAxis, renderer);
    return new JFreeChart(plot);
}

From source file:com.opensymphony.xwork2.conversion.impl.StringConverterTest.java

public void testFloatToStringConversionPL() throws Exception {
    // given//from  w w  w. java 2  s. c  om
    StringConverter converter = new StringConverter();
    Map<String, Object> context = new HashMap<>();
    context.put(ActionContext.LOCALE, new Locale("pl", "PL"));

    // when has max fraction digits
    Object value = converter.convertValue(context, null, null, null, Float.MIN_VALUE, null);

    // then does not lose fraction digits
    assertEquals("0," + StringUtils.repeat('0', 44) + "14", value);

    // when has max integer digits
    value = converter.convertValue(context, null, null, null, Float.MAX_VALUE, null);

    // then does not lose integer digits
    assertEquals("34028235" + StringUtils.repeat('0', 31), value);

    // when cannot be represented exactly with a finite binary number
    value = converter.convertValue(context, null, null, null, 0.1f, null);

    // then produce the shortest decimal representation that can unambiguously identify the true value of the floating-point number
    assertEquals("0,1", value);
}

From source file:org.apache.hadoop.mapred.GenReduce.java

@Override
public void reduce(Text key, Iterator<Text> values, OutputCollector<Text, Text> output, Reporter reporter)
        throws IOException {
    FSDataOutputStream out = null;/*  ww w  . j a  v a  2  s  .c  o  m*/
    try {
        int size = 0;
        FileSystem fs = FileSystem.get(conf);
        double averageIORate = 0;
        List<Float> list = new ArrayList<Float>();

        String output_dir = conf.get(OUTPUT_DIR_KEY);
        Path result_file = new Path(output_dir, "results");
        if (fs.exists(result_file)) {
            fs.delete(result_file);
        }
        out = fs.create(result_file, true);

        long nmaps = conf.getLong(NUMBER_OF_MAPS_KEY, NMAPS);
        long nthreads = conf.getLong(NUMBER_OF_THREADS_KEY, NTHREADS);

        out.writeChars("-----------------------------\n");
        out.writeChars("Number of mapper :\t\t\t" + nmaps + "\n");
        out.writeChars("Number of threads :\t\t\t" + nthreads + "\n");

        float min = Float.MAX_VALUE;
        float max = Float.MIN_VALUE;
        Class<?> clazz = conf.getClass(THREAD_CLASS_KEY, null);
        if (clazz == null) {
            throw new IOException("Class " + conf.get(THREAD_CLASS_KEY) + " not found");
        }
        GenThread t = (GenThread) ReflectionUtils.newInstance(clazz, conf);
        t.reset();
        long total_files = 0;
        long total_processed_size = 0;
        long total_num_errors = 0;
        String total_error = "";
        TypeReference<Map<String, String>> type = new TypeReference<Map<String, String>>() {
        };
        while (values.hasNext()) {
            Map<String, String> stat = mapper.readValue(values.next().toString(), type);
            size++;
            total_files += Long.parseLong(stat.get("files"));
            total_processed_size += Long.parseLong(stat.get("size"));
            total_num_errors += Long.parseLong(stat.get("nerrors"));
            total_error += stat.get("errors");
            double ioRate = Double.parseDouble(stat.get("rate"));
            if (ioRate > max)
                max = (float) ioRate;
            if (ioRate < min)
                min = (float) ioRate;
            list.add((float) ioRate);
            averageIORate += ioRate;
            t.analyze(stat);
        }

        out.writeChars("Number of files processed:\t\t" + total_files + "\n");
        out.writeChars("Number of size processed:\t\t" + total_processed_size + "\n");
        out.writeChars("Min IO Rate(MB/sec): \t\t\t" + min + "\n");
        out.writeChars("Max IO Rate(MB/sec): \t\t\t" + max + "\n");
        averageIORate /= size;
        float temp = (float) 0.0;
        for (int i = 0; i < list.size(); i++) {
            temp += Math.pow(list.get(i) - averageIORate, 2);
        }
        out.writeChars("Average(MB/sec): \t\t\t" + averageIORate + "\n");
        float dev = (float) Math.sqrt(temp / size);
        out.writeChars("Std. dev: \t\t\t\t" + dev + "\n");
        out.writeChars("Total number of errors:\t\t\t" + total_num_errors + "\n");
        out.writeChars(total_error);
        t.output(out);
    } catch (IOException e) {
        LOG.error("Error:", e);
        throw e;
    } finally {
        out.close();

    }
}

From source file:org.thymeleaf.util.EvaluationUtilTest.java

@Test
public void convertToBooleanTest() {

    Assert.assertFalse(EvaluationUtil.evaluateAsBoolean(null));

    Assert.assertTrue(EvaluationUtil.evaluateAsBoolean(Boolean.TRUE));
    Assert.assertFalse(EvaluationUtil.evaluateAsBoolean(Boolean.FALSE));

    Assert.assertFalse(EvaluationUtil.evaluateAsBoolean(BigDecimal.ZERO));
    Assert.assertTrue(EvaluationUtil.evaluateAsBoolean(BigDecimal.ONE));
    Assert.assertTrue(EvaluationUtil.evaluateAsBoolean(BigDecimal.TEN));

    Assert.assertFalse(EvaluationUtil.evaluateAsBoolean(BigInteger.ZERO));
    Assert.assertTrue(EvaluationUtil.evaluateAsBoolean(BigInteger.ONE));
    Assert.assertTrue(EvaluationUtil.evaluateAsBoolean(BigInteger.TEN));

    Assert.assertFalse(EvaluationUtil.evaluateAsBoolean(Double.valueOf(0.0d)));
    Assert.assertFalse(EvaluationUtil.evaluateAsBoolean(Float.valueOf(0.0f)));
    Assert.assertTrue(EvaluationUtil.evaluateAsBoolean(Double.valueOf(0.1d)));
    Assert.assertTrue(EvaluationUtil.evaluateAsBoolean(Float.valueOf(0.1f)));
    Assert.assertTrue(EvaluationUtil.evaluateAsBoolean(Double.valueOf(-0.1d)));
    Assert.assertTrue(EvaluationUtil.evaluateAsBoolean(Float.valueOf(-0.1f)));
    Assert.assertTrue(EvaluationUtil.evaluateAsBoolean(Double.valueOf(Double.MAX_VALUE)));
    Assert.assertTrue(EvaluationUtil.evaluateAsBoolean(Float.valueOf(Float.MAX_VALUE)));
    Assert.assertTrue(EvaluationUtil.evaluateAsBoolean(Double.valueOf(Double.MIN_VALUE)));
    Assert.assertTrue(EvaluationUtil.evaluateAsBoolean(Float.valueOf(Float.MIN_VALUE)));

    Assert.assertFalse(EvaluationUtil.evaluateAsBoolean(Character.valueOf((char) 0)));
    Assert.assertTrue(EvaluationUtil.evaluateAsBoolean(Character.valueOf('x')));
    Assert.assertTrue(EvaluationUtil.evaluateAsBoolean(Character.valueOf('0')));
    Assert.assertTrue(EvaluationUtil.evaluateAsBoolean(Character.valueOf('1')));

    Assert.assertTrue(EvaluationUtil.evaluateAsBoolean("true"));
    Assert.assertFalse(EvaluationUtil.evaluateAsBoolean("false"));
    Assert.assertTrue(EvaluationUtil.evaluateAsBoolean("yes"));
    Assert.assertFalse(EvaluationUtil.evaluateAsBoolean("no"));
    Assert.assertTrue(EvaluationUtil.evaluateAsBoolean("on"));
    Assert.assertFalse(EvaluationUtil.evaluateAsBoolean("off"));
    Assert.assertTrue(EvaluationUtil.evaluateAsBoolean("sky"));
    Assert.assertTrue(EvaluationUtil.evaluateAsBoolean("high above"));

    Assert.assertTrue(EvaluationUtil.evaluateAsBoolean(new LiteralValue("true")));
    Assert.assertFalse(EvaluationUtil.evaluateAsBoolean(new LiteralValue("false")));
    Assert.assertTrue(EvaluationUtil.evaluateAsBoolean(new LiteralValue("yes")));
    Assert.assertFalse(EvaluationUtil.evaluateAsBoolean(new LiteralValue("no")));
    Assert.assertTrue(EvaluationUtil.evaluateAsBoolean(new LiteralValue("on")));
    Assert.assertFalse(EvaluationUtil.evaluateAsBoolean(new LiteralValue("off")));
    Assert.assertTrue(EvaluationUtil.evaluateAsBoolean(new LiteralValue("sky")));
    Assert.assertTrue(EvaluationUtil.evaluateAsBoolean(new LiteralValue("high above")));

    Assert.assertTrue(EvaluationUtil.evaluateAsBoolean(EvaluationUtil.class));

}