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:org.vertx.java.http.eventbusbridge.integration.MessageSendTest.java

@Test
public void testSendingFloatJson() throws IOException {
    final EventBusMessageType messageType = EventBusMessageType.Float;
    final Float sentFloat = Float.MAX_VALUE;
    Map<String, String> expectations = createExpectations("someaddress",
            Base64.encodeAsString(sentFloat.toString()), messageType);
    Handler<Message> messageConsumerHandler = new MessageSendHandler(sentFloat, expectations);
    vertx.eventBus().registerHandler(expectations.get("address"), messageConsumerHandler);
    String body = TemplateHelper.generateOutputUsingTemplate(SEND_REQUEST_TEMPLATE_JSON, expectations);
    HttpRequestHelper.sendHttpPostRequest(url, body, (VertxInternal) vertx, Status.ACCEPTED.getStatusCode(),
            MediaType.APPLICATION_JSON);
}

From source file:br.gov.frameworkdemoiselle.internal.configuration.ConfigurationLoaderWithArrayTest.java

@Test
public void testConfigurationPropertiesWithFloatArray() {
    ConfigurationPropertiesWithArray config = prepareConfigurationPropertiesWithArray();

    Float floatValue = config.floatArray[0];

    assertEquals(Float.class, floatValue.getClass());
    assertEquals(Float.MAX_VALUE, floatValue.floatValue(), 1);
    assertEquals(5, config.floatArray.length);
}

From source file:br.gov.frameworkdemoiselle.internal.configuration.ConfigurationLoaderWithListTest.java

@Test
public void testConfigurationPropertiesWithFloatList() {
    ConfigurationPropertiesWithList config = prepareConfigurationPropertiesWithList();

    Float floatValue = config.floatList.get(0);

    assertEquals(Float.class, floatValue.getClass());
    assertEquals(Float.MAX_VALUE, floatValue.floatValue(), 1);
    assertEquals(5, config.floatList.size());
}

From source file:org.ballerinalang.stdlib.io.data.DataInputOutputTest.java

@DataProvider(name = "DoubleValues")
public static Object[][] doubleValues() {
    return new Object[][] { { 0.0f, BIT_32 }, { 0.0f, BIT_64 }, { -1.0f, BIT_32 }, { -1.0f, BIT_64 },
            { Float.MIN_VALUE, BIT_32 }, { Float.MIN_VALUE, BIT_64 }, { Float.MAX_VALUE, BIT_32 },
            { Float.MAX_VALUE, BIT_64 }, { Double.MIN_VALUE, BIT_64 }, { Double.MAX_VALUE, BIT_64 } };
}

From source file:org.araqne.confdb.file.ShrinkTest.java

private Object createObject(int id) throws UnknownHostException {
    double doubleData = Math.PI;
    float floatData = Float.MAX_VALUE;
    String stringData = "test number " + id;
    boolean boolData = (id % 2) == 0 ? true : false;
    Date dateData = new Date();
    Object nullData = null;/*  www.  jav  a 2  s .com*/
    Inet4Address ip4Data = (Inet4Address) Inet4Address.getByName("172.0.0.1");
    Inet6Address ip6Data = (Inet6Address) Inet6Address.getByName("1080:0:0:0:8:800:200C:417A");
    Object o1 = "object1";
    Object o2 = "object2";
    long longData = Long.MAX_VALUE;
    Short shortData = Short.MAX_VALUE;
    Object[] os = new Object[2];
    os[0] = o1;
    os[1] = o2;
    int[] i = new int[] { 1, 2, 3 };

    Map<String, Object> m = new HashMap<String, Object>();

    m.put("int", id);
    m.put("double", doubleData);
    m.put("float", floatData);
    m.put("string", stringData);
    m.put("bool", boolData);
    m.put("date", dateData);
    m.put("null", nullData);
    m.put("ip4", ip4Data);
    m.put("ip6", ip6Data);
    m.put("byte", createByteArray());
    m.put("object", os);
    m.put("long", longData);
    m.put("short", shortData);
    m.put("int_array", i);

    return m;
}

From source file:ExposedFloat.java

public boolean action(Event evt, Object arg) {

    if (evt.target instanceof Button) {
        String bname = (String) arg;
        if (bname.equals(incrementButtonString)) {

            ++value;/*w w  w .  j  a v a 2 s. c o m*/
        } else if (bname.equals(decrementButtonString)) {

            --value;
        } else if (bname.equals(multByZeroButtonString)) {

            value *= (float) 0.0;
        } else if (bname.equals(piButtonString)) {

            value = (float) Math.PI;
        } else if (bname.equals(positiveInfinityButtonString)) {

            value = Float.POSITIVE_INFINITY;
        } else if (bname.equals(negativeInfinityButtonString)) {

            value = Float.NEGATIVE_INFINITY;
        } else if (bname.equals(maximumButtonString)) {

            value = Float.MAX_VALUE;
        } else if (bname.equals(minimumButtonString)) {

            value = Float.MIN_VALUE;
        } else if (bname.equals(notANumberButtonString)) {

            value = Float.NaN;
        } else if (bname.equals(changeSignButtonString)) {

            value *= -1.0;
        } else if (bname.equals(doubleButtonString)) {

            value *= 2.0;
        } else if (bname.equals(halveButtonString)) {

            value /= 2.0;
        }
        updateNumberFields();
        enableDisableButton(maximumButton, Float.MAX_VALUE);
        enableDisableButton(minimumButton, Float.MIN_VALUE);
        enableDisableButton(positiveInfinityButton, Float.POSITIVE_INFINITY);
        enableDisableButton(negativeInfinityButton, Float.NEGATIVE_INFINITY);
        enableDisableButton(piButton, (float) Math.PI);
        enableDisableButton(notANumberButton, Float.NaN);
        if (!notANumberButton.isEnabled()) {
            if (!Float.isNaN(value)) {
                notANumberButton.enable();
            }
        } else if (Float.isNaN(value)) {
            notANumberButton.disable();
        }
    }
    return true;
}

From source file:javadz.beanutils.locale.converters.FloatLocaleConverter.java

/**
 * Convert the specified locale-sensitive input object into an output object of the
 * specified type.  This method will return Float value or throw exception if value
 * can not be stored in the Float.//w  ww  . ja  v  a 2s.  c o m
 *
 * @param value The input object to be converted
 * @param pattern The pattern is used for the convertion
 * @return The converted value
 *
 * @exception ConversionException if conversion cannot be performed
 *  successfully
 * @throws ParseException if an error occurs parsing a String to a Number
 */
protected Object parse(Object value, String pattern) throws ParseException {
    final Number parsed = (Number) super.parse(value, pattern);
    double doubleValue = parsed.doubleValue();
    double posDouble = (doubleValue >= (double) 0) ? doubleValue : (doubleValue * (double) -1);
    if (posDouble != 0 && (posDouble < Float.MIN_VALUE || posDouble > Float.MAX_VALUE)) {
        throw new ConversionException("Supplied number is not of type Float: " + parsed);
    }
    return new Float(parsed.floatValue()); // unlike superclass it returns Float type
}

From source file:it.geosolutions.imageio.plugins.nitronitf.ImageIOUtils.java

public static float[] findMinAndMax(float[] buffer, int pixelStride, int numBands) {
    float min = Float.MAX_VALUE;
    float max = -Float.MAX_VALUE;
    for (int i = 0; i < buffer.length; i += numBands) {
        for (int j = 0; j < pixelStride; ++j) {
            float value = buffer[i + j];
            if (!Float.isInfinite(value)) {
                if (value < min)
                    min = value;//from  w w w . j  a  v  a  2  s .  c  o m
                if (value > max)
                    max = value;
            }
        }
    }
    return new float[] { min, max };
}

From source file:de.ma.it.common.excel.ExcelFileManager.java

/**
 * //ww  w. j  a  v  a  2 s.  c o  m
 * @param row
 * @param cellIdx
 * @return
 * @throws IllegalArgumentException
 */
public Float readCellAsFloat(HSSFRow row, int cellIdx) throws IllegalArgumentException {
    HSSFCell cell = getCell(row, cellIdx);
    if (cell == null) {
        return null;
    }

    int cellType = cell.getCellType();
    // First evaluate formula if present
    if (cellType == HSSFCell.CELL_TYPE_FORMULA) {
        cellType = evaluator.evaluateFormulaCell(cell);
    }

    Float result;
    switch (cellType) {
    case HSSFCell.CELL_TYPE_NUMERIC:
        double numericCellValue = cell.getNumericCellValue();
        if (numericCellValue > Float.MAX_VALUE) {
            throw new IllegalArgumentException("Value " + numericCellValue + " to big for integer!");
        }
        result = Double.valueOf(numericCellValue).floatValue();
        break;
    case HSSFCell.CELL_TYPE_STRING:
        String stringCellValue = cell.getStringCellValue();
        if (!StringUtils.isNumeric(stringCellValue)) {
            throw new IllegalArgumentException("Value " + stringCellValue + " is not numeric!");
        }
        result = Double.valueOf(stringCellValue).floatValue();
        break;
    default:
        result = Float.MIN_VALUE;
        break;
    }

    return result;
}

From source file:com.jeeframework.util.validate.GenericTypeValidator.java

/**
 *  Checks if the value can safely be converted to a float primitive.
 *
 *@param  value   The value validation is being performed on.
 *@param  locale  The locale to use to parse the number (system default if
 *      null)/*from   w  ww  . j  a  v  a 2 s  . c o  m*/
 *@return the converted Float value.
 */
public static Float formatFloat(String value, Locale locale) {
    Float result = null;

    if (value != null) {
        NumberFormat formatter = null;
        if (locale != null) {
            formatter = NumberFormat.getInstance(locale);
        } else {
            formatter = NumberFormat.getInstance(Locale.getDefault());
        }
        ParsePosition pos = new ParsePosition(0);
        Number num = formatter.parse(value, pos);

        // If there was no error      and we used the whole string
        if (pos.getErrorIndex() == -1 && pos.getIndex() == value.length()) {
            if (num.doubleValue() >= (Float.MAX_VALUE * -1) && num.doubleValue() <= Float.MAX_VALUE) {
                result = new Float(num.floatValue());
            }
        }
    }

    return result;
}