本文整理匯總了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;
}