本文整理了Java中java.lang.Math.pow()
方法的一些代码示例,展示了Math.pow()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Math.pow()
方法的具体详情如下:
包路径:java.lang.Math
类名称:Math
方法名:pow
[英]Returns the closest double approximation of the result of raising x to the power of y.
Special cases:
代码示例来源:origin: libgdx/libgdx
public float apply (float a) {
if (a <= 0.5f) return (float)Math.pow(a * 2, power) / 2;
return (float)Math.pow((a - 1) * 2, power) / (power % 2 == 0 ? -2 : 2) + 1;
}
}
代码示例来源:origin: libgdx/libgdx
public int reset () {
low = min;
high = max;
current = (low + high) >>> 1;
if (pot) return (int)Math.pow(2, current);
if (mod4) return current % 4 == 0 ? current : current + 4 - (current % 4);
return current;
}
代码示例来源:origin: libgdx/libgdx
public float apply (float a) {
if (a <= 0.5f) return ((float)Math.pow(value, power * (a * 2 - 1)) - min) * scale / 2;
return (2 - ((float)Math.pow(value, -power * (a * 2 - 1)) - min) * scale) / 2;
}
};
代码示例来源:origin: libgdx/libgdx
public Exp (float value, float power) {
this.value = value;
this.power = power;
min = (float)Math.pow(value, -power);
scale = 1 / (1 - min);
}
代码示例来源:origin: libgdx/libgdx
public Exp (float value, float power) {
this.value = value;
this.power = power;
min = (float)Math.pow(value, -power);
scale = 1 / (1 - min);
}
代码示例来源:origin: libgdx/libgdx
public int reset () {
low = min;
high = max;
current = (low + high) >>> 1;
if (pot) return (int)Math.pow(2, current);
if (mod4) return current % 4 == 0 ? current : current + 4 - (current % 4);
return current;
}
代码示例来源:origin: libgdx/libgdx
public float apply (float a) {
if (a <= 0.5f) return ((float)Math.pow(value, power * (a * 2 - 1)) - min) * scale / 2;
return (2 - ((float)Math.pow(value, -power * (a * 2 - 1)) - min) * scale) / 2;
}
};
代码示例来源:origin: stackoverflow.com
public static String humanReadableByteCount(long bytes, boolean si) {
int unit = si ? 1000 : 1024;
if (bytes < unit) return bytes + " B";
int exp = (int) (Math.log(bytes) / Math.log(unit));
String pre = (si ? "kMGTPE" : "KMGTPE").charAt(exp-1) + (si ? "" : "i");
return String.format("%.1f %sB", bytes / Math.pow(unit, exp), pre);
}
代码示例来源:origin: stackoverflow.com
public static double round(double value, int places) {
if (places < 0) throw new IllegalArgumentException();
long factor = (long) Math.pow(10, places);
value = value * factor;
long tmp = Math.round(value);
return (double) tmp / factor;
}
代码示例来源:origin: apache/incubator-dubbo
private static int parseInt(String version) {
int v = 0;
String[] vArr = version.split("\\.");
int len = vArr.length;
for (int i = 0; i < len; i++) {
v += Integer.parseInt(getDigital(vArr[i])) * Math.pow(10, (len - i - 1) * 2);
}
return v;
}
代码示例来源:origin: apache/incubator-dubbo
private static int parseInt(String version) {
int v = 0;
String[] vArr = version.split("\\.");
int len = vArr.length;
for (int i = 0; i < len; i++) {
v += Integer.parseInt(getDigital(vArr[i])) * Math.pow(10, (len - i - 1) * 2);
}
return v;
}
代码示例来源:origin: libgdx/libgdx
public float apply (float a) {
if (a == 0) return 0;
a = 1 - a;
return (1 - (float)Math.pow(value, power * (a - 1)) * MathUtils.sin(a * bounces) * scale);
}
}
代码示例来源:origin: libgdx/libgdx
public float apply (float a) {
if (a <= 0.5f) {
a *= 2;
return (float)Math.pow(value, power * (a - 1)) * MathUtils.sin(a * bounces) * scale / 2;
}
a = 1 - a;
a *= 2;
return 1 - (float)Math.pow(value, power * (a - 1)) * MathUtils.sin((a) * bounces) * scale / 2;
}
}
代码示例来源:origin: libgdx/libgdx
public float apply (float a) {
if (a >= 0.99) return 1;
return (float)Math.pow(value, power * (a - 1)) * MathUtils.sin(a * bounces) * scale;
}
}
代码示例来源:origin: alibaba/druid
public static Histogram makeHistogram(int rangeCount) {
long[] rangeValues = new long[rangeCount];
for (int i = 0; i < rangeValues.length; ++i) {
rangeValues[i] = (long) Math.pow(10, i);
}
return new Histogram(rangeValues);
}
代码示例来源:origin: libgdx/libgdx
public float apply (float a) {
if (a == 0) return 0;
a = 1 - a;
return (1 - (float)Math.pow(value, power * (a - 1)) * MathUtils.sin(a * bounces) * scale);
}
}
代码示例来源:origin: libgdx/libgdx
public float apply (float a) {
if (a <= 0.5f) {
a *= 2;
return (float)Math.pow(value, power * (a - 1)) * MathUtils.sin(a * bounces) * scale / 2;
}
a = 1 - a;
a *= 2;
return 1 - (float)Math.pow(value, power * (a - 1)) * MathUtils.sin((a) * bounces) * scale / 2;
}
}
代码示例来源:origin: google/guava
/**
* Returns the probability that {@linkplain #mightContain(Object)} will erroneously return {@code
* true} for an object that has not actually been put in the {@code BloomFilter}.
*
* <p>Ideally, this number should be close to the {@code fpp} parameter passed in {@linkplain
* #create(Funnel, int, double)}, or smaller. If it is significantly higher, it is usually the
* case that too many elements (more than expected) have been put in the {@code BloomFilter},
* degenerating it.
*
* @since 14.0 (since 11.0 as expectedFalsePositiveProbability())
*/
public double expectedFpp() {
// You down with FPP? (Yeah you know me!) Who's down with FPP? (Every last homie!)
return Math.pow((double) bits.bitCount() / bitSize(), numHashFunctions);
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void SPR9486_floatPowerFloat() {
Number expectedResult = Math.pow(10.21f, -10.2f);
ExpressionParser parser = new SpelExpressionParser();
StandardEvaluationContext context = new StandardEvaluationContext();
Expression expression = parser.parseExpression("10.21f ^ -10.2f");
Number result = expression.getValue(context, null, Number.class);
assertEquals(expectedResult, result);
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void SPR9486_floatPowerDouble() {
Number expectedResult = Math.pow(10.21f, 10.2);
ExpressionParser parser = new SpelExpressionParser();
StandardEvaluationContext context = new StandardEvaluationContext();
Expression expression = parser.parseExpression("10.21f ^ 10.2");
Number result = expression.getValue(context, null, Number.class);
assertEquals(expectedResult, result);
}
内容来源于网络,如有侵权,请联系作者删除!