下面列出了java.lang.Math#floor ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
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;
}
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);
}
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");
}
public static int xTile(double lon, int zoom) {
return (int) Math.floor((lon + 180) / 360 * (1 << zoom));
}
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));
}
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;
}
public static MR_double floor ( MR_double x ) { return new MR_double(Math.floor(x.get())); }