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:Main.java

public static android.location.Location getLastBestLocation(Context _context) {
    if (locManager == null)
        locManager = (LocationManager) _context.getSystemService(Context.LOCATION_SERVICE);

    int minDistance = (int) 500;
    long minTime = System.currentTimeMillis() - (900 * 1000);

    android.location.Location bestResult = null;

    float bestAccuracy = Float.MAX_VALUE;
    long bestTime = Long.MIN_VALUE;

    // Iterate through all the providers on the system, keeping
    // note of the most accurate result within the acceptable time limit.
    // If no result is found within maxTime, return the newest Location.
    List<String> matchingProviders = locManager.getAllProviders();
    for (String provider : matchingProviders) {
        android.location.Location location = locManager.getLastKnownLocation(provider);
        if (location != null) {
            //                log(TAG, " location: " + location.getLatitude() + "," + location.getLongitude() + "," + location.getAccuracy() + "," + location.getSpeed() + "m/s");
            float accuracy = location.getAccuracy();
            long time = location.getTime();
            //                log(TAG, "time>minTime: " + (time > minTime) + ", accuracy<bestAccuracy: " + (accuracy < bestAccuracy));
            //                if ((time > minTime && accuracy < bestAccuracy)) {
            if (accuracy < bestAccuracy) {
                bestResult = location;/* w w  w  .j  a v a 2 s  .  c  o m*/
                bestAccuracy = accuracy;
                bestTime = time;
            }
        }
    }

    return bestResult;
}

From source file:Main.java

public static float getDisplayDensity(Context context) {
    if (sDensity == Float.MAX_VALUE) {
        Display display = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE))
                .getDefaultDisplay();// w ww .  ja v  a2s .  co  m
        DisplayMetrics metrics = new DisplayMetrics();
        display.getMetrics(metrics);
        sDensity = metrics.density;
    }
    return sDensity;
}

From source file:Main.java

public static float setTextSizeForWidth(Paint paint, float desiredWidth, String text) {
    return setTextSizeForWidth(paint, desiredWidth, text, Float.MAX_VALUE, 0.0f);
}

From source file:qtiscoringengine.AreaMapping.java

static AreaMapping fromXML(Element node, XmlNamespaceManager nsmgr, ValidationLog log) throws Exception {
    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
        log.addMessage(node, "Could not parse float value for defaultValue. Value attempted: '" + defVal + "'");
        fDefault.set(Float.MIN_VALUE);
    }// ww w .  j  a  v a 2s.c  o  m

    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 + "'");

    List<Element> entries = new XmlElement(node).selectNodes(QTIXmlConstants.AreaMapEntry, nsmgr);
    List<AreaMapEntry> entryList = new ArrayList<AreaMapEntry>();

    for (Element me : entries) {
        AreaMapEntry e = AreaMapEntry.fromXML(me, nsmgr, log);
        if (e != null)
            entryList.add(e);
    }

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

From source file:edu.emory.mathcs.nlp.learning.util.MLUtils.java

static public int argmax(float[] scores, IntCollection labels) {
    if (labels == null || labels.isEmpty())
        return argmax(scores);
    float maxValue = -Float.MAX_VALUE;
    int maxIndex = -1;

    for (int i : labels) {
        if (maxValue < scores[i]) {
            maxIndex = i;// w ww . j  a v a 2s  .com
            maxValue = scores[i];
        }
    }

    return maxIndex;
}

From source file:org.mrgeo.aggregators.MinAggregator.java

@Override
public float aggregate(float[] values, float nodata) {
    Float min = Float.MAX_VALUE;
    for (int i = 0; i < values.length; i++) {
        if (Float.compare(values[i], nodata) != 0)
            min = Math.min(min, values[i]);
    }/*  w  ww  .  j  a v  a 2s .  c  om*/
    return (min == Float.MAX_VALUE) ? nodata : min;
}

From source file:org.mrgeo.aggregators.MaxAggregator.java

@Override
public float aggregate(float[] values, float nodata) {
    Float max = -Float.MAX_VALUE;
    for (int i = 0; i < values.length; i++) {
        if (Float.compare(values[i], nodata) != 0)
            max = Math.max(max, values[i]);
    }/*  ww  w.  j  a va  2s .c om*/
    return (max == -Float.MAX_VALUE) ? nodata : max;
}

From source file:org.tmjee.miniwiki.radeox.macro.table.MinFunction.java

public void execute(Table table, int posx, int posy, int startX, int startY, int endX, int endY) {
    float min = Float.MAX_VALUE;
    boolean floating = false;
    for (int x = startX; x <= endX; x++) {
        for (int y = startY; y <= endY; y++) {
            //Logger.debug("x="+x+" y="+y+" >"+getXY(x,y));
            float value = 0;
            try {
                value += Integer.parseInt((String) table.getXY(x, y));
            } catch (Exception e) {
                try {
                    value += Float.parseFloat((String) table.getXY(x, y));
                    floating = true;//from  w w w.j  a  v a  2  s  . co  m
                } catch (NumberFormatException e1) {
                    log.debug("SumFunction: unable to parse " + table.getXY(x, y));
                }
            }
            if (min > value) {
                min = value;
            }
        }
    }
    //Logger.debug("Sum="+sum);
    if (floating) {
        table.setXY(posx, posy, "" + min);
    } else {
        table.setXY(posx, posy, "" + (int) min);
    }
}

From source file:org.radeox.macro.table.MinFunction.java

public void execute(Table table, int posx, int posy, int startX, int startY, int endX, int endY) {
    float min = Float.MAX_VALUE;
    boolean floating = false;
    for (int x = startX; x <= endX; x++) {
        for (int y = startY; y <= endY; y++) {
            // Logger.debug("x="+x+" y="+y+" >"+getXY(x,y));
            float value = 0;
            try {
                value += Integer.parseInt((String) table.getXY(x, y));
            } catch (Exception e) {
                try {
                    value += Float.parseFloat((String) table.getXY(x, y));
                    floating = true;/*from  ww  w. j  a  v a2s  .  co m*/
                } catch (NumberFormatException e1) {
                    log.debug("SumFunction: unable to parse " + table.getXY(x, y));
                }
            }
            if (min > value) {
                min = value;
            }
        }
    }
    // Logger.debug("Sum="+sum);
    if (floating) {
        table.setXY(posx, posy, "" + min);
    } else {
        table.setXY(posx, posy, "" + (int) min);
    }
}

From source file:Main.java

public static float min(float[] f) {
    float min = Float.MAX_VALUE;
    for (float ff : f)
        if (ff < min)
            min = ff;//www  .java  2 s. com
    return min;
}