List of usage examples for java.lang Float MAX_VALUE
float MAX_VALUE
To view the source code for java.lang Float MAX_VALUE.
Click Source Link
From source file:Main.java
/** * Fills the array with random floats. Values will be between min (inclusive) and * max (inclusive)./*from w w w. ja v a 2s. c o m*/ */ public static void genRandomFloats(long seed, float min, float max, float array[], boolean includeExtremes) { Random r = new Random(seed); int minExponent = Math.min(Math.getExponent(min), 0); int maxExponent = Math.max(Math.getExponent(max), 0); if (minExponent < -6 || maxExponent > 6) { // Use an exponential distribution int exponentDiff = maxExponent - minExponent; for (int i = 0; i < array.length; i++) { float mantissa = r.nextFloat(); int exponent = minExponent + r.nextInt(maxExponent - minExponent); int sign = (min >= 0) ? 1 : 1 - r.nextInt(2) * 2; // -1 or 1 float rand = sign * mantissa * (float) Math.pow(2.0, exponent); if (rand < min || rand > max) { continue; } array[i] = rand; } } else { // Use a linear distribution for (int i = 0; i < array.length; i++) { float rand = r.nextFloat(); array[i] = min + rand * (max - min); } } // Seed a few special numbers we want to be sure to test. for (int i = 0; i < sInterestingDoubles.length; i++) { float f = (float) sInterestingDoubles[i]; if (min <= f && f <= max) { array[r.nextInt(array.length)] = f; } } array[r.nextInt(array.length)] = min; array[r.nextInt(array.length)] = max; if (includeExtremes) { array[r.nextInt(array.length)] = Float.NaN; array[r.nextInt(array.length)] = Float.POSITIVE_INFINITY; array[r.nextInt(array.length)] = Float.NEGATIVE_INFINITY; array[r.nextInt(array.length)] = Float.MIN_VALUE; array[r.nextInt(array.length)] = Float.MIN_NORMAL; array[r.nextInt(array.length)] = Float.MAX_VALUE; array[r.nextInt(array.length)] = -Float.MIN_VALUE; array[r.nextInt(array.length)] = -Float.MIN_NORMAL; array[r.nextInt(array.length)] = -Float.MAX_VALUE; } }
From source file:net.sf.jasperreports.engine.util.JRFloatLocaleConverter.java
@Override protected Object parse(Object value, String pattern) throws ParseException { final Number parsed = (Number) super.parse(value, pattern); double doubleValue = parsed.doubleValue(); double posDouble = (doubleValue >= 0) ? doubleValue : (doubleValue * -1); if ((posDouble > 0 && posDouble < Float.MIN_VALUE) || posDouble > Float.MAX_VALUE) { throw new ConversionException("Supplied number is not of type Float: " + parsed); }/*from w w w.java 2 s .com*/ return parsed.floatValue(); // unlike superclass it returns Float type }
From source file:com.opengamma.maths.lowlevelapi.functions.utilities.Min.java
/** * Returns the index of the minimum value in data * @param data the data to search//from w w w . ja va 2 s. c om * @return idx, the index of the minimum value in the data */ public static int index(float... data) { Validate.notNull(data); float min = Float.MAX_VALUE; int idx = -1; final int n = data.length; for (int i = 0; i < n; i++) { if (data[i] < min) { min = data[i]; idx = i; } } return idx; }
From source file:org.cellcore.code.engine.page.extractor.mfrag.MFRAGPageDataExtractor.java
@Override protected int getStock(Document doc) { Elements trs = doc.select("#Tableau").get(0).children().get(0).children(); float iPrice = Float.MAX_VALUE; int iStock = 0; for (int i = 1; i < trs.size(); i++) { Element tr = trs.get(i);/*from w ww .j a v a 2s. com*/ String val = tr.select("td").get(3).select("strong").get(0).childNodes().get(0).attr("text"); String stockV = tr.select("td").get(4).select("option").last().childNodes().get(0).attr("text"); val = cleanPriceString(val); float price = Float.parseFloat(val); if (price < iPrice) { iPrice = price; iStock = Integer.parseInt(stockV.replaceAll("\\(", "").replaceAll("\\)", "")); } } return iStock; }
From source file:org.joda.primitives.iterator.impl.TestArrayFloatIterator.java
@Override public Iterator<Float> makeFullIterator() { float[] data = 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) }; return new ArrayFloatIterator(data); }
From source file:org.dbpedia.spotlight.lucene.similarity.NewSimilarity.java
private float round(float d) { float result = d; DecimalFormat twoDForm = new DecimalFormat("#.######"); if (Float.isInfinite(d)) { result = Float.MAX_VALUE; } else if (Float.isNaN(d)) { result = -2;/*from ww w . ja v a2 s . c o m*/ } else { result = Float.valueOf(twoDForm.format(d)); } return result; }
From source file:org.cellcore.code.engine.page.extractor.AbstractPageDataExtractor.java
private Card extract(Document doc, String url) throws UnsupportedCardException { Card card = getCard(getName(doc));/*from w w w.jav a 2 s .com*/ card.setOtherSearchNames(getOtherNames(doc)); float iPrice = getPrice(doc); if (iPrice == Float.MAX_VALUE) { throw new UnsupportedCardException("Unavailable"); } int stock = getStock(doc); setPriceDetails(card, iPrice, stock, url, getSource()); logger.debug(card.getName() + " => " + iPrice + " (" + stock + ")"); return card; }
From source file:com.liferay.alloy.util.DefaultValueUtil.java
public static String getDefaultValue(String className, String value) { String defaultValue = StringPool.BLANK; if (className.equals(ArrayList.class.getName()) || className.equals(HashMap.class.getName()) || className.equals(Object.class.getName()) || className.equals(String.class.getName())) { if (!isValidStringValue(value)) { return defaultValue; }/* ww w . j a va 2 s . c o m*/ if (_EMPTY_STRINGS.contains(value)) { value = StringPool.BLANK; } else if (className.equals(ArrayList.class.getName()) && !StringUtil.startsWith(value.trim(), StringPool.OPEN_BRACKET)) { value = "[]"; } else if (className.equals(HashMap.class.getName()) && !StringUtil.startsWith(value.trim(), StringPool.OPEN_CURLY_BRACE)) { value = "{}"; } defaultValue = StringUtil.unquote(value); } else if (className.equals(boolean.class.getName()) || className.equals(Boolean.class.getName())) { defaultValue = String.valueOf(GetterUtil.getBoolean(value)); } else if (className.equals(int.class.getName()) || className.equals(Integer.class.getName())) { if (_INFINITY.contains(value)) { value = String.valueOf(Integer.MAX_VALUE); } defaultValue = String.valueOf(GetterUtil.getInteger(value)); } else if (className.equals(double.class.getName()) || className.equals(Double.class.getName())) { if (_INFINITY.contains(value)) { value = String.valueOf(Double.MAX_VALUE); } defaultValue = String.valueOf(GetterUtil.getDouble(value)); } else if (className.equals(float.class.getName()) || className.equals(Float.class.getName())) { if (_INFINITY.contains(value)) { value = String.valueOf(Float.MAX_VALUE); } defaultValue = String.valueOf(GetterUtil.getFloat(value)); } else if (className.equals(long.class.getName()) || className.equals(Long.class.getName())) { if (_INFINITY.contains(value)) { value = String.valueOf(Long.MAX_VALUE); } defaultValue = String.valueOf(GetterUtil.getLong(value)); } else if (className.equals(short.class.getName()) || className.equals(Short.class.getName())) { if (_INFINITY.contains(value)) { value = String.valueOf(Short.MAX_VALUE); } defaultValue = String.valueOf(GetterUtil.getShort(value)); } else if (className.equals(Number.class.getName())) { if (_INFINITY.contains(value)) { value = String.valueOf(Integer.MAX_VALUE); } defaultValue = String.valueOf(GetterUtil.getNumber(value)); } return defaultValue; }
From source file:rndvecgen.RandomQueryGen.java
void setNN(QueryVector qvec) throws Exception { int numDimensions = qvec.getNumberofDimensions(); int numIntervals = qvec.getNumberofIntervals(); float minDist = Float.MAX_VALUE; int minDocId = 0; DocVector minDocVector = null;//from ww w . jav a 2s .co m float dist; System.out.println("Computing NN info between vecs: "); for (int i = 0; i < numDocs; i++) { DocVector dvec = new DocVector(vecLines.get(i), numDimensions, numIntervals); dist = dvec.getDist(qvec); if (dist < minDist) { minDist = dist; minDocId = i; minDocVector = dvec; } } qvec.setNNInfo(minDocId, minDist); System.out.println("Query: " + qvec); System.out.println("NN-vec wrt query: " + minDocVector); }
From source file:com.jaeksoft.searchlib.result.collector.collapsing.CollapseDistanceCollector.java
public CollapseDistanceCollector(final CollapseBaseCollector base, final DistanceInterface distanceInterface) { super(base);/*from w ww. j ava 2 s. co m*/ this.sourceDistances = distanceInterface.getDistances(); distanceCollector = new FloatBufferedArray(this.sourceDistances.length); maxDistance = 0; minDistance = Float.MAX_VALUE; currentPos = 0; distances = null; collapsedDistances = new float[base.getIds().length][]; }