java.lang.Math.floorDiv()方法的使用及代码示例

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

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

Math.floorDiv介绍

暂无

代码示例

代码示例来源:origin: SonarSource/sonarqube

static String formatNumeric(long value) {
 if (value == 0) {
  return ZERO;
 }
 NumberFormat numericFormatter = DecimalFormat.getInstance(Locale.ENGLISH);
 numericFormatter.setMaximumFractionDigits(1);
 int power = (int) StrictMath.log10(value);
 double valueToFormat = value / (Math.pow(10, Math.floorDiv(power, 3) * 3d));
 String formattedNumber = numericFormatter.format(valueToFormat);
 formattedNumber = formattedNumber + NUMERIC_SUFFIX_LIST.charAt(power / 3);
 return formattedNumber.length() > 4 ? trim(formattedNumber.replaceAll(NUMERIC_REGEXP, "")) : trim(formattedNumber);
}

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

TreeNodeFixedSize( int pageSize, Layout<KEY,VALUE> layout )
{
  super( pageSize, layout );
  this.keySize = layout.keySize( null );
  this.valueSize = layout.valueSize( null );
  this.internalMaxKeyCount = Math.floorDiv( pageSize - (BASE_HEADER_LENGTH + SIZE_PAGE_REFERENCE),
      keySize + SIZE_PAGE_REFERENCE);
  this.leafMaxKeyCount = Math.floorDiv( pageSize - BASE_HEADER_LENGTH, keySize + valueSize );
  if ( internalMaxKeyCount < 2 )
  {
    throw new MetadataMismatchException(
        "For layout %s a page size of %d would only fit %d internal keys, minimum is 2",
        layout, pageSize, internalMaxKeyCount );
  }
  if ( leafMaxKeyCount < 2 )
  {
    throw new MetadataMismatchException( "A page size of %d would only fit leaf keys, minimum is 2",
        pageSize, leafMaxKeyCount );
  }
}

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

/**
 * Get the number of milliseconds past midnight of the given {@link java.time.LocalDateTime}, {@link java.time.LocalDate},
 * {@link java.time.LocalTime}, {@link java.util.Date}, {@link java.sql.Date}, {@link java.sql.Time}, or
 * {@link java.sql.Timestamp}, ignoring any date portions of the supplied value.
 * 
 * @param value the local or SQL date, time, or timestamp value; may not be null
 * @param adjuster the optional component that adjusts the local date value before obtaining the epoch day; may be null if no
 * adjustment is necessary
 * @return the milliseconds past midnight
 * @throws IllegalArgumentException if the value is not an instance of the acceptable types
 */
public static int toMilliOfDay(Object value, TemporalAdjuster adjuster) {
  LocalTime time = Conversions.toLocalTime(value);
  if (adjuster != null) {
    time = time.with(adjuster);
  }
  long micros = Math.floorDiv(time.toNanoOfDay(), Conversions.NANOSECONDS_PER_MILLISECOND);
  assert Math.abs(micros) < Integer.MAX_VALUE;
  return (int) micros;
}

代码示例来源:origin: kiegroup/optaplanner

int solverBenchmarkResultCount = plannerBenchmarkResult.getSolverBenchmarkResultList().size();
int cyclesCount = ConfigUtils.ceilDivide(solverBenchmarkResultCount, parallelBenchmarkCount);
long timeLeftPerCycle = Math.floorDiv(timeLeftTotal, cyclesCount);
Map<ProblemBenchmarkResult, List<ProblemStatistic>> originalProblemStatisticMap
    = new HashMap<>(plannerBenchmarkResult.getUnifiedProblemBenchmarkResultList().size());

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

/**
 * Get the number of microseconds past midnight of the given {@link java.time.LocalDateTime}, {@link java.time.LocalDate},
 * {@link java.time.LocalTime}, {@link java.util.Date}, {@link java.sql.Date}, {@link java.sql.Time}, or
 * {@link java.sql.Timestamp}, ignoring any date portions of the supplied value.
 * 
 * @param value the local or SQL date, time, or timestamp value; may not be null
 * @param adjuster the optional component that adjusts the local date value before obtaining the epoch day; may be null if no
 * adjustment is necessary
 * @return the microseconds past midnight
 * @throws IllegalArgumentException if the value is not an instance of the acceptable types
 */
public static long toMicroOfDay(Object value, TemporalAdjuster adjuster) {
  LocalTime time = Conversions.toLocalTime(value);
  if (adjuster != null) {
    time = time.with(adjuster);
  }
  return Math.floorDiv(time.toNanoOfDay(), Conversions.NANOSECONDS_PER_MICROSECOND);
}

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

/**
 * Get the number of microseconds past epoch of the given {@link java.time.LocalDateTime}, {@link java.time.LocalDate},
 * {@link java.time.LocalTime}, {@link java.util.Date}, {@link java.sql.Date}, {@link java.sql.Time}, or
 * {@link java.sql.Timestamp}.
 * 
 * @param value the local or SQL date, time, or timestamp value; may not be null
 * @param adjuster the optional component that adjusts the local date value before obtaining the epoch day; may be null if no
 * adjustment is necessary
 * @return the epoch microseconds
 * @throws IllegalArgumentException if the value is not an instance of the acceptable types
 */
public static long toEpochMicros(Object value, TemporalAdjuster adjuster) {
  LocalDateTime dateTime = Conversions.toLocalDateTime(value);
  if (adjuster != null) {
    dateTime = dateTime.with(adjuster);
  }
  long epochNanos = Conversions.toEpochNanos(dateTime);
  return Math.floorDiv(epochNanos, Conversions.NANOSECONDS_PER_MICROSECOND);
}

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

/**
 * Get the number of milliseconds past epoch of the given {@link java.time.LocalDateTime}, {@link java.time.LocalDate},
 * {@link java.time.LocalTime}, {@link java.util.Date}, {@link java.sql.Date}, {@link java.sql.Time}, or
 * {@link java.sql.Timestamp}.
 * 
 * @param value the local or SQL date, time, or timestamp value; may not be null
 * @param adjuster the optional component that adjusts the local date value before obtaining the epoch day; may be null if no
 * adjustment is necessary
 * @return the epoch milliseconds
 * @throws IllegalArgumentException if the value is not an instance of the acceptable types
 */
public static long toEpochMillis(Object value, TemporalAdjuster adjuster) {
  if (value instanceof Long) {
    return (Long)value;
  }
  LocalDateTime dateTime = Conversions.toLocalDateTime(value);
  if (adjuster != null) {
    dateTime = dateTime.with(adjuster);
  }
  long epochNanos = Conversions.toEpochNanos(dateTime);
  return Math.floorDiv(epochNanos, Conversions.NANOSECONDS_PER_MILLISECOND);
}

代码示例来源:origin: prestodb/presto

long millisSinceEpoch = (long) value;
  long secondsAndNanos = (Math.floorDiv(millisSinceEpoch, 1000L) << 30) + Math.floorMod(millisSinceEpoch, 1000);
  return (int) ((secondsAndNanos >>> 32) ^ secondsAndNanos);
default:

代码示例来源:origin: jtablesaw/tablesaw

public static int plusMonths(int months, int packedDate) {
  if (months == 0) {
    return packedDate;
  }
  byte d = getDayOfMonth(packedDate);
  byte m = getMonthValue(packedDate);
  short y = getYear(packedDate);
  long monthCount = y * 12L + (m - 1);
  long calcMonths = monthCount + months;
  int newYear = YEAR.checkValidIntValue(Math.floorDiv((int) calcMonths, 12));
  int newMonth = Math.floorMod((int) calcMonths, 12) + 1;
  return resolvePreviousValid(newYear, newMonth, d);
}

代码示例来源:origin: prestodb/presto

long millisSinceEpoch = prestoType.getLong(block, position);
  long secondsAndNanos = (Math.floorDiv(millisSinceEpoch, 1000L) << 30) + Math.floorMod(millisSinceEpoch, 1000);
  return (int) ((secondsAndNanos >>> 32) ^ secondsAndNanos);
default:

代码示例来源:origin: fossasia/pslab-android

public double[] fftFrequency(int n, double space) {
  /*
  Return the Discrete Fourier Transform sample frequencies.
  The returned array contains the frequency bin centers in cycles
  per unit of the sample spacing (with zero at the start).  For instance, if
  the sample spacing is in seconds, then the frequency unit is cycles/second.
  Given a window length `n` and a sample spacing `spacing`.
   */
  double value = 1.0 / (n * space);
  int N = Math.floorDiv(n - 1, 2) + 1;
  double[] results = new double[n];
  for (int i = 0; i < N; i++) {
    results[i] = i;
    results[i] = results[i] * value;
  }
  int j = N;
  for (int i = -Math.floorDiv(n, 2); i < 0; i++) {
    results[j] = i;
    results[j] = results[j] * value;
    j++;
  }
  return results;
}

代码示例来源:origin: stackoverflow.com

// use INSTANT_SECONDS, thus this code is not bound by Instant.MAX
Long inSec = context.getValue(INSTANT_SECONDS);
if (inSec >= -SECONDS_0000_TO_1970) {
  // current era
  long zeroSecs = inSec - SECONDS_PER_10000_YEARS + SECONDS_0000_TO_1970;
  long hi = Math.floorDiv(zeroSecs, SECONDS_PER_10000_YEARS) + 1;
  long lo = Math.floorMod(zeroSecs, SECONDS_PER_10000_YEARS);
  LocalDateTime ldt = LocalDateTime.ofEpochSecond(lo - SECONDS_0000_TO_1970, 0, ZoneOffset.UTC);
  if (hi > 0) {
     buf.append('+').append(hi);
  }
  buf.append(ldt);
}

代码示例来源:origin: magefree/mage

@Override
  protected PreventionEffectData preventDamageAction(GameEvent event, Ability source, Game game) {
    return game.preventDamage(event, source, game, Math.floorDiv(event.getAmount(), 2) + (event.getAmount() % 2));
  }
}

代码示例来源:origin: magefree/mage

@Override
  public boolean apply(Game game, Ability source) {
    int islandCount = new PermanentsOnBattlefieldCount(filter2).calculate(game, source, this);
    islandCount = Math.floorDiv(islandCount, 2);
    return new DamageAllEffect(islandCount, filter).apply(game, source);
  }
}

代码示例来源:origin: org.elasticsearch/elasticsearch

int maxShardsPerPath = Math.floorDiv(shardCount, paths.length) + ((shardCount % paths.length) == 0 ? 0 : 1);

代码示例来源:origin: magefree/mage

@Override
  public boolean apply(Game game, Ability source) {
    Permanent permanent = game.getPermanent(targetPointer.getFirst(game, source));
    if (permanent == null || !permanent.isCreature()) {
      return false;
    }
    int unBoost = -1 * Math.floorDiv(permanent.getPower().getValue(), 2);
    game.addEffect(new BoostTargetEffect(unBoost, 0), source);
    return true;
  }
}

代码示例来源:origin: magefree/mage

@Override
  public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Player player = game.getPlayer(source.getFirstTarget());
    if (controller == null || player == null) {
      return false;
    }
    controller.gainLife(controller.getLife(), game, source);
    int life = player.getLife();
    player.loseLife(Math.floorDiv(life, 2) + (life % 2), game, false);
    return true;
  }
}

代码示例来源:origin: magefree/mage

@Override
  public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
      return false;
    }
    Object obj = getValue(CastSourceTriggeredAbility.SOURCE_CAST_SPELL_ABILITY);
    if (!(obj instanceof SpellAbility)) {
      return false;
    }
    int halfCost = Math.floorDiv(((SpellAbility) obj).getManaCostsToPay().getX(), 2);
    player.drawCards(halfCost, game);
    player.gainLife(halfCost, game, source);
    return true;
  }
}

代码示例来源:origin: stackoverflow.com

static int floorDiv(int x, int y) {    
  return Math.floorDiv(x, y);
}

static int floorMod(int x, int y) {    
  return Math.floorMod(x, y);
}

代码示例来源:origin: broadinstitute/picard

@Override
  public int deduceIdealSplitWeight(final IntervalList intervalList, final int nCount) {
    return (int) Math.max(1, Math.floorDiv(listWeight(intervalList), nCount));
  }
}

相关文章