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:com.opengamma.maths.lowlevelapi.functions.utilities.Min.java

/**
 * Returns the minimum value in data/*from   w w w.j a  v  a  2s  .  co m*/
 * @param data the data to search
 * @return min, the minimum
 */
public static float value(float... data) {
    Validate.notNull(data);
    float min = Float.MAX_VALUE;
    final int n = data.length;
    for (int i = 0; i < n; i++) {
        if (data[i] < min) {
            min = data[i];
        }
    }
    return min;
}

From source file:qtiscoringengine.VariableMapping.java

static VariableMapping fromXML(Element node, BaseType bt, XmlNamespaceManager nsmgr, ValidationLog log) {
    if (node == null)
        return null;

    String defVal = node.getAttributeValue("defaultValue"); // required!
    String upper = node.getAttributeValue("upperBound");
    String lower = node.getAttributeValue("lowerBound");

    _Ref<Float> fDefault = new _Ref<>(Float.MIN_VALUE);
    _Ref<Float> fUpper = new _Ref<>(Float.MAX_VALUE);
    _Ref<Float> fLower = new _Ref<>(Float.MIN_VALUE);

    if (!JavaPrimitiveUtils.floatTryParse(defVal, fDefault))// this is required
                                                            // so return null
                                                            // if it fails
    {/*from w w  w . j a  v a2  s. c o m*/
        log.addMessage(node, "Could not parse float value for defaultValue. Value attempted: '" + defVal + "'");
        fDefault.set(Float.MIN_VALUE);
    }
    if (!StringUtils.isEmpty(upper))
        if (!JavaPrimitiveUtils.floatTryParse(upper, fUpper))
            log.addMessage(node,
                    "Could not parse float value for upperBound. Value attempted: '" + upper + "'");
    if (!StringUtils.isEmpty(lower))
        if (!JavaPrimitiveUtils.floatTryParse(lower, fLower))
            log.addMessage(node,
                    "Could not parse float value for lowerBound. Value attempted: '" + lower + "'");

    // XmlNodeList entries = node.SelectNodes("qti:mapEntry",nsmgr);
    List<Element> entries = new XmlElement(node).selectNodes("qti:mapEntry", nsmgr);
    List<VariableMapEntry> entryList = new ArrayList<VariableMapEntry>();

    for (Element me : entries) {
        VariableMapEntry e = VariableMapEntry.FromXML(me, bt, log);
        if (e != null)
            entryList.add(e);
    }

    return new VariableMapping(entryList, fDefault.get(), fUpper.get(), fLower.get(), node);
}

From source file:com.bstek.dorado.view.resolver.IE6PngFileResolver.java

protected Resource[] getResourcesByFileName(DoradoContext context, String resourcePrefix, String fileName,
        String resourceSuffix) throws Exception {
    String ua = context.getRequest().getHeader("User-Agent");
    if (ua.indexOf(CHROME_FRAME) < 0) {
        boolean isMSIE = (ua != null && ua.indexOf(MSIE) != -1);
        if (isMSIE) {
            float version = NumberUtils.toFloat(MSIE_VERSION_PATTERN.matcher(ua).replaceAll("$1"),
                    Float.MAX_VALUE);
            if (version < 7) {
                fileName = fileName.replace(PNG24_DIR, PNG8_DIR);
            }/*www . ja  va  2s.c  o  m*/
        }
    }
    return super.getResourcesByFileName(context, resourcePrefix, fileName, resourceSuffix);
}

From source file:gridool.routing.selector.LoadBalancingNodeSelector.java

@Override
public GridNode selectNode(List<GridNode> nodeList, GridConfiguration config) {
    final int size = nodeList.size();
    if (size == 0) {
        return null;
    } else if (size == 1) {
        return nodeList.get(0);
    }/* w w  w  . j a v  a 2 s  .  co m*/

    final GridLoadProbe probe = config.getProbe();
    GridNode node = null;
    float minLoad = Float.MAX_VALUE;
    for (int i = 0; i < size; i++) {
        GridNode n = nodeList.get(i);
        float load = probe.getLoad(n);
        if (load < minLoad) {
            node = n;
            minLoad = load;
        }
    }
    if (LOG.isInfoEnabled()) {
        LOG.info("Node `" + node + "' of load=" + minLoad + " is selected");
    }
    return node;
}

From source file:com.bstek.dorado.view.resolver.FontAwesomePngFileResolver.java

protected Resource[] getResourcesByFileName(DoradoContext context, String resourcePrefix, String fileName,
        String resourceSuffix) throws Exception {
    String ua = context.getRequest().getHeader("User-Agent");
    if (ua.indexOf(CHROME_FRAME) < 0) {
        boolean isMSIE = (ua != null && ua.indexOf(MSIE) != -1);
        if (isMSIE) {
            float version = NumberUtils.toFloat(MSIE_VERSION_PATTERN.matcher(ua).replaceAll("$1"),
                    Float.MAX_VALUE);
            if (version < 8) {
                fileName = fileName.replace(REQUEST_URI, TARGET_URI);
            }//from  w ww  .j av  a 2  s .  c om
        }
    }
    return super.getResourcesByFileName(context, resourcePrefix, fileName, resourceSuffix);
}

From source file:org.cellcore.code.engine.page.extractor.mcc.MCCPageDataExtractor.java

@Override
protected float getPrice(Document doc) {
    Elements tr = doc.select("#blockContent").get(5).select("tr");
    float iPrice = Float.MAX_VALUE;
    for (int i = 0; i < tr.size(); i++) {
        try {/*from www  . j  av a2  s . c o  m*/
            String val = tr.get(i).getElementsByTag("td").get(3).childNodes().get(0).attr("text");
            val = cleanPriceString(val);
            float price = Float.parseFloat(val);
            if (price < iPrice) {
                iPrice = price;
            }
        } catch (Throwable t) {

        }
    }
    if (iPrice == Float.MAX_VALUE) {
        iPrice = -1;
    }
    return iPrice;
}

From source file:it.acubelab.smaph.SmaphUtils.java

/**
 * For each word of bold, finds the word in query that has the minimum edit
 * distance, normalized by the word length. Put that word in minTokens.
 * Returns the average of those distances.
 * /*from  w w  w .  ja  v  a2  s .  c om*/
 * @param query
 *            a query.
 * @param bold
 *            a bold.
 * @param minTokens
 *            the tokens of query having minimum edit distance.
 * @return the averaged normalized word-by-word edit distance of bold
 *         against query.
 */
public static double getMinEditDist(String query, String bold, List<String> minTokens) {
    List<String> tokensQ = tokenize(query);
    List<String> tokensB = tokenize(bold);

    if (tokensB.size() == 0 || tokensQ.size() == 0)
        return 1;

    float avgMinDist = 0;
    for (String tokenB : tokensB) {
        float minDist = Float.MAX_VALUE;
        String bestQToken = null;
        for (String tokenQ : tokensQ) {
            float relLev = getNormEditDistance(tokenB, tokenQ);
            if (relLev < minDist) {
                minDist = relLev;
                bestQToken = tokenQ;
            }
        }
        if (minTokens != null)
            minTokens.add(bestQToken);
        avgMinDist += minDist;
    }
    return avgMinDist / tokensB.size();
}

From source file:com.bstek.dorado.view.resolver.OldIconsFileResolver.java

protected ResourcesWrapper createResourcesWrapper(HttpServletRequest request, DoradoContext context)
        throws Exception {
    String resourceType = PNG;/*from  w ww  .ja v  a 2s . c o  m*/
    String ua = request.getHeader("User-Agent");
    if (ua.indexOf(CHROME_FRAME) < 0) {
        boolean isMSIE = (ua != null && ua.indexOf(MSIE) != -1);
        if (isMSIE) {
            float version = NumberUtils.toFloat(MSIE_VERSION_PATTERN.matcher(ua).replaceAll("$1"),
                    Float.MAX_VALUE);
            if (version < 7) {
                resourceType = GIF;
            }
        }
    }

    Resource[] resources = context.getResources(ICON_PATH + resourceType);
    return new ResourcesWrapper(resources, getResourceTypeManager().getResourceType(resourceType));
}

From source file:main.StratioENEI.java

private static float calculate(float[][] custos, int cidadeInicial, int cidadeFinal, List<String> ordem) {

    // System.out.printf("%d -> %d\n", cidadeInicial, cidadeFinal);
    ordem.clear();//from   w w  w . ja va2s .  c om
    ordem.add(0, String.valueOf(cidadeInicial));
    ordem.add(1, String.valueOf(cidadeFinal));
    int i;
    for (i = 0; i < custos.length; i++) {
        if (ordem.contains(String.valueOf(i))) {
            continue;
        }
        float minimo = Float.MAX_VALUE;
        int idxMin = 1;
        //   System.out.println(i);
        for (int j = 1; j < ordem.size(); j++) {
            //     System.out.printf(">%d|%d\n>>B4: %s\n",i, j, ordem);
            ordem.add(j, String.valueOf(i));
            //      System.out.printf(">>After: %s\n", ordem);
            float value = calcCost(ordem, custos);
            //  System.out.println("Value: "+value);
            ordem.remove(j);

            if (value < minimo) {
                minimo = value;
                idxMin = j;
            }
        }
        ordem.add(idxMin, String.valueOf(i));
        //    System.out.println(ordem);
    }
    return calcCost(ordem, custos);
}

From source file:org.cellcore.code.engine.page.extractor.mb.MBPageDataExtractor.java

protected float getPrice(Document doc) {
    if (!doc.getElementsContainingText("Cette carte n'est pas disponible en stock").isEmpty()) {
        return -1;
    }/*from ww  w .j  a va  2s.  c  o  m*/
    Elements tr = doc.select(".stock").get(0).getElementsByTag("tr");
    float iPrice = Float.MAX_VALUE;
    for (int i = 1; i < tr.size(); i++) {
        String val = tr.get(i).getElementsByTag("td").get(3).childNodes().get(0).attr("text");
        val = cleanPriceString(val);
        float price = Float.parseFloat(val);
        if (price < iPrice) {
            iPrice = price;
        }
    }
    return iPrice;
}