Java Code Examples for java.lang.Math#floor()

The following examples show how to use java.lang.Math#floor() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Histogram.java    From relex with Apache License 2.0 6 votes vote down vote up
public void bin(double value)
{
	int b = (int) Math.floor (rate * (value - min_value));

	if (b < 0)
	{
		underflow ++;
	}
	else if (b >= nbins)
	{
		overflow ++;
	}
	else
	{
		bins[b] ++;
	}

	if (value < all_time_low) all_time_low = value;
	if (value > all_time_high) all_time_high = value;

	cnt ++;
	sum += value;
	sumsq += value*value;
}
 
Example 2
Source File: NumBitsOperatorTest.java    From zserio with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private short calculateExpectedNumBits(long value)
{
    if (value <= 0)
        return (short)0;
    if (value == 1)
        return (short)1;

    return (short)(Math.floor(Math.log((double)(value - 1)) / Math.log(2.0)) + 1);
}
 
Example 3
Source File: Floor.java    From Llunatic with GNU General Public License v3.0 5 votes vote down vote up
public Object floor(Object param)
	throws ParseException
{
	if (param instanceof Number)
	{
		return new Double(Math.floor(((Number)param).doubleValue()));
	}

	throw new ParseException("Invalid parameter type");
}
 
Example 4
Source File: WebMercatorTile.java    From osm-lib with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public static int xTile(double lon, int zoom) {
    return (int) Math.floor((lon + 180) / 360 * (1 << zoom));
}
 
Example 5
Source File: WebMercatorTile.java    From osm-lib with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public static int yTile(double lat, int zoom) {
    return (int) Math.floor((1 - Math.log(Math.tan(Math.toRadians(lat))
            + 1 / Math.cos(Math.toRadians(lat))) / Math.PI) / 2 * (1 << zoom));
}
 
Example 6
Source File: ParseStats.java    From relex with Apache License 2.0 4 votes vote down vote up
public String toString()
{
	double failed = 100.0 * ((double) failed_parses) / ((double) count);
	int pf = (int) Math.floor(failed+0.5);

	double overflow = 100.0 * ((double) parse_count.getOverflow()) / ((double) count);
	int ovfl = (int) Math.floor(overflow+0.5);

	String str = "";
	str += "\nTotal sentences: " + count;
	str += "\nFailed parses: " + failed_parses +
	       " Percent failed: " + pf + "%" +
	       " (these are parses with one or more words skipped)";
	str += "\nWords per sentence: " + word_count.getMean();
	str += "\nParses per sentence, mode: " + parse_count.getMode() +
	       " median: " + parse_count.getMedian() +
	       " mean: " +  parse_count.getMean() +
	       " stddev: " + parse_count.getStdDev();
	str += "\nsentences with more than " + max_parses + " parses: " +
	       parse_count.getOverflow() + " as percent: " + ovfl + "%";
	str += "\nRelations per parse, mode: " + relations.getMode() +
	       " median: " + relations.getMedian() +
	       " mean: " +  relations.getMean() +
	       " stddev: " + relations.getStdDev();
	str += "\nConfidence of first parse: " + first_parse_confidence.getMean() +
	       " (out of " + first_parse_confidence.getCount() + " parses)";
	str += "\nFirst parse hi/lo: " + first_parse_confidence.getAllTimeHigh() +
	       " / " + first_parse_confidence.getAllTimeLow();
	str += " stddev: " + first_parse_confidence.getStdDev();
	str += "\nConfidence of second parse: " + second_parse_confidence.getMean() +
	       " (out of " + second_parse_confidence.getCount() + " parses)";
	str += ", stddev: " + second_parse_confidence.getStdDev();
	str += "\nConfidence of third parse: " + third_parse_confidence.getMean() +
	       " (out of " + third_parse_confidence.getCount() + " parses)";
	str += ", stddev: " + third_parse_confidence.getStdDev();
	str += "\nConfidence of fourth parse: " + fourth_parse_confidence.getMean() +
	       " (out of " + fourth_parse_confidence.getCount() + " parses)";
	str += ", stddev: " + fourth_parse_confidence.getStdDev();

	str += "\n";
	return str;
}
 
Example 7
Source File: SystemFunctions.java    From incubator-retired-mrql with Apache License 2.0 votes vote down vote up
public static MR_double floor ( MR_double x ) { return new MR_double(Math.floor(x.get())); }