java.math.BigDecimal.roundingBehavior()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(7.5k)|赞(0)|评价(0)|浏览(209)

本文整理了Java中java.math.BigDecimal.roundingBehavior()方法的一些代码示例,展示了BigDecimal.roundingBehavior()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。BigDecimal.roundingBehavior()方法的具体详情如下:
包路径:java.math.BigDecimal
类名称:BigDecimal
方法名:roundingBehavior

BigDecimal.roundingBehavior介绍

[英]Return an increment that can be -1,0 or 1, depending of roundingMode.
[中]返回一个增量,该增量可以是-1,0或1,具体取决于取整模式。

代码示例

代码示例来源:origin: robovm/robovm

private static BigDecimal dividePrimitiveLongs(long scaledDividend, long scaledDivisor, int scale, RoundingMode roundingMode) {
  long quotient = scaledDividend / scaledDivisor;
  long remainder = scaledDividend % scaledDivisor;
  int sign = Long.signum( scaledDividend ) * Long.signum( scaledDivisor );
  if (remainder != 0) {
    // Checking if:  remainder * 2 >= scaledDivisor
    int compRem;                                      // 'compare to remainder'
    compRem = longCompareTo(Math.abs(remainder) * 2,Math.abs(scaledDivisor));
    // To look if there is a carry
    quotient += roundingBehavior(((int)quotient) & 1,
        sign * (5 + compRem),
        roundingMode);
  }
  // Constructing the result with the appropriate unscaled value
  return valueOf(quotient, scale);
}

代码示例来源:origin: robovm/robovm

compRem = longCompareTo(Math.abs(rem) * 2,Math.abs(divisor));
compRem = roundingBehavior(quotient.testBit(0) ? 1 : 0,
    sign * (5 + compRem), roundingMode);
compRem = roundingBehavior(quotient.testBit(0) ? 1 : 0,
    sign * (5 + compRem), roundingMode);

代码示例来源:origin: robovm/robovm

integer += roundingBehavior( ((int)integer) & 1,
    Long.signum(fraction) * (5 + compRem),
    mc.getRoundingMode());

代码示例来源:origin: robovm/robovm

compRem =  roundingBehavior( integerAndFraction[0].testBit(0) ? 1 : 0,
    integerAndFraction[1].signum() * (5 + compRem),
    mc.getRoundingMode());

代码示例来源:origin: com.mobidevelop.robovm/robovm-rt

private static BigDecimal dividePrimitiveLongs(long scaledDividend, long scaledDivisor, int scale, RoundingMode roundingMode) {
  long quotient = scaledDividend / scaledDivisor;
  long remainder = scaledDividend % scaledDivisor;
  int sign = Long.signum( scaledDividend ) * Long.signum( scaledDivisor );
  if (remainder != 0) {
    // Checking if:  remainder * 2 >= scaledDivisor
    int compRem;                                      // 'compare to remainder'
    compRem = longCompareTo(Math.abs(remainder) * 2,Math.abs(scaledDivisor));
    // To look if there is a carry
    quotient += roundingBehavior(((int)quotient) & 1,
        sign * (5 + compRem),
        roundingMode);
  }
  // Constructing the result with the appropriate unscaled value
  return valueOf(quotient, scale);
}

代码示例来源:origin: com.bugvm/bugvm-rt

private static BigDecimal dividePrimitiveLongs(long scaledDividend, long scaledDivisor, int scale, RoundingMode roundingMode) {
  long quotient = scaledDividend / scaledDivisor;
  long remainder = scaledDividend % scaledDivisor;
  int sign = Long.signum( scaledDividend ) * Long.signum( scaledDivisor );
  if (remainder != 0) {
    // Checking if:  remainder * 2 >= scaledDivisor
    int compRem;                                      // 'compare to remainder'
    compRem = longCompareTo(Math.abs(remainder) * 2,Math.abs(scaledDivisor));
    // To look if there is a carry
    quotient += roundingBehavior(((int)quotient) & 1,
        sign * (5 + compRem),
        roundingMode);
  }
  // Constructing the result with the appropriate unscaled value
  return valueOf(quotient, scale);
}

代码示例来源:origin: com.gluonhq/robovm-rt

private static BigDecimal dividePrimitiveLongs(long scaledDividend, long scaledDivisor, int scale, RoundingMode roundingMode) {
  long quotient = scaledDividend / scaledDivisor;
  long remainder = scaledDividend % scaledDivisor;
  int sign = Long.signum( scaledDividend ) * Long.signum( scaledDivisor );
  if (remainder != 0) {
    // Checking if:  remainder * 2 >= scaledDivisor
    int compRem;                                      // 'compare to remainder'
    compRem = longCompareTo(Math.abs(remainder) * 2,Math.abs(scaledDivisor));
    // To look if there is a carry
    quotient += roundingBehavior(((int)quotient) & 1,
        sign * (5 + compRem),
        roundingMode);
  }
  // Constructing the result with the appropriate unscaled value
  return valueOf(quotient, scale);
}

代码示例来源:origin: MobiVM/robovm

private static BigDecimal dividePrimitiveLongs(long scaledDividend, long scaledDivisor, int scale, RoundingMode roundingMode) {
  long quotient = scaledDividend / scaledDivisor;
  long remainder = scaledDividend % scaledDivisor;
  int sign = Long.signum( scaledDividend ) * Long.signum( scaledDivisor );
  if (remainder != 0) {
    // Checking if:  remainder * 2 >= scaledDivisor
    int compRem;                                      // 'compare to remainder'
    compRem = longCompareTo(Math.abs(remainder) * 2,Math.abs(scaledDivisor));
    // To look if there is a carry
    quotient += roundingBehavior(((int)quotient) & 1,
        sign * (5 + compRem),
        roundingMode);
  }
  // Constructing the result with the appropriate unscaled value
  return valueOf(quotient, scale);
}

代码示例来源:origin: ibinti/bugvm

private static BigDecimal dividePrimitiveLongs(long scaledDividend, long scaledDivisor, int scale, RoundingMode roundingMode) {
  long quotient = scaledDividend / scaledDivisor;
  long remainder = scaledDividend % scaledDivisor;
  int sign = Long.signum( scaledDividend ) * Long.signum( scaledDivisor );
  if (remainder != 0) {
    // Checking if:  remainder * 2 >= scaledDivisor
    int compRem;                                      // 'compare to remainder'
    compRem = longCompareTo(Math.abs(remainder) * 2,Math.abs(scaledDivisor));
    // To look if there is a carry
    quotient += roundingBehavior(((int)quotient) & 1,
        sign * (5 + compRem),
        roundingMode);
  }
  // Constructing the result with the appropriate unscaled value
  return valueOf(quotient, scale);
}

代码示例来源:origin: FlexoVM/flexovm

private static BigDecimal dividePrimitiveLongs(long scaledDividend, long scaledDivisor, int scale, RoundingMode roundingMode) {
  long quotient = scaledDividend / scaledDivisor;
  long remainder = scaledDividend % scaledDivisor;
  int sign = Long.signum( scaledDividend ) * Long.signum( scaledDivisor );
  if (remainder != 0) {
    // Checking if:  remainder * 2 >= scaledDivisor
    int compRem;                                      // 'compare to remainder'
    compRem = longCompareTo(Math.abs(remainder) * 2,Math.abs(scaledDivisor));
    // To look if there is a carry
    quotient += roundingBehavior(((int)quotient) & 1,
        sign * (5 + compRem),
        roundingMode);
  }
  // Constructing the result with the appropriate unscaled value
  return valueOf(quotient, scale);
}

代码示例来源:origin: MobiVM/robovm

compRem = longCompareTo(Math.abs(rem) * 2,Math.abs(divisor));
compRem = roundingBehavior(quotient.testBit(0) ? 1 : 0,
    sign * (5 + compRem), roundingMode);
compRem = roundingBehavior(quotient.testBit(0) ? 1 : 0,
    sign * (5 + compRem), roundingMode);

代码示例来源:origin: ibinti/bugvm

compRem = longCompareTo(Math.abs(rem) * 2,Math.abs(divisor));
compRem = roundingBehavior(quotient.testBit(0) ? 1 : 0,
    sign * (5 + compRem), roundingMode);
compRem = roundingBehavior(quotient.testBit(0) ? 1 : 0,
    sign * (5 + compRem), roundingMode);

代码示例来源:origin: com.gluonhq/robovm-rt

compRem = longCompareTo(Math.abs(rem) * 2,Math.abs(divisor));
compRem = roundingBehavior(quotient.testBit(0) ? 1 : 0,
    sign * (5 + compRem), roundingMode);
compRem = roundingBehavior(quotient.testBit(0) ? 1 : 0,
    sign * (5 + compRem), roundingMode);

代码示例来源:origin: FlexoVM/flexovm

compRem = longCompareTo(Math.abs(rem) * 2,Math.abs(divisor));
compRem = roundingBehavior(quotient.testBit(0) ? 1 : 0,
    sign * (5 + compRem), roundingMode);
compRem = roundingBehavior(quotient.testBit(0) ? 1 : 0,
    sign * (5 + compRem), roundingMode);

代码示例来源:origin: com.mobidevelop.robovm/robovm-rt

compRem = longCompareTo(Math.abs(rem) * 2,Math.abs(divisor));
compRem = roundingBehavior(quotient.testBit(0) ? 1 : 0,
    sign * (5 + compRem), roundingMode);
compRem = roundingBehavior(quotient.testBit(0) ? 1 : 0,
    sign * (5 + compRem), roundingMode);

代码示例来源:origin: com.bugvm/bugvm-rt

compRem = longCompareTo(Math.abs(rem) * 2,Math.abs(divisor));
compRem = roundingBehavior(quotient.testBit(0) ? 1 : 0,
    sign * (5 + compRem), roundingMode);
compRem = roundingBehavior(quotient.testBit(0) ? 1 : 0,
    sign * (5 + compRem), roundingMode);

代码示例来源:origin: ibinti/bugvm

integer += roundingBehavior( ((int)integer) & 1,
    Long.signum(fraction) * (5 + compRem),
    mc.getRoundingMode());

代码示例来源:origin: MobiVM/robovm

integer += roundingBehavior( ((int)integer) & 1,
    Long.signum(fraction) * (5 + compRem),
    mc.getRoundingMode());

代码示例来源:origin: FlexoVM/flexovm

integer += roundingBehavior( ((int)integer) & 1,
    Long.signum(fraction) * (5 + compRem),
    mc.getRoundingMode());

代码示例来源:origin: com.mobidevelop.robovm/robovm-rt

integer += roundingBehavior( ((int)integer) & 1,
    Long.signum(fraction) * (5 + compRem),
    mc.getRoundingMode());

相关文章