本文整理汇总了Java中org.apache.commons.math3.util.FastMath.copySign方法的典型用法代码示例。如果您正苦于以下问题:Java FastMath.copySign方法的具体用法?Java FastMath.copySign怎么用?Java FastMath.copySign使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.math3.util.FastMath
的用法示例。
在下文中一共展示了FastMath.copySign方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getProjection
import org.apache.commons.math3.util.FastMath; //导入方法依赖的package包/类
/** Get the projection.
* @return projection
*/
public BoundaryProjection<S> getProjection() {
// fix offset sign
offset = FastMath.copySign(offset, (Boolean) leaf.getAttribute() ? -1 : +1);
return new BoundaryProjection<S>(original, projected, offset);
}
示例2: round
import org.apache.commons.math3.util.FastMath; //导入方法依赖的package包/类
/**
* Rounds the given value to the specified number of decimal places.
* The value is rounded using the given method which is any method defined
* in {@link BigDecimal}.
*
* @param x Value to round.
* @param scale Number of digits to the right of the decimal point.
* @param roundingMethod Rounding method as defined in {@link BigDecimal}.
* @return the rounded value.
* @since 1.1 (previously in {@code MathUtils}, moved as of version 3.0)
*/
public static float round(float x, int scale, int roundingMethod) {
final float sign = FastMath.copySign(1f, x);
final float factor = (float) FastMath.pow(10.0f, scale) * sign;
return (float) roundUnscaled(x * factor, sign, roundingMethod) / factor;
}