@Override public String getTranscribedSequence() { String sequence = getSequence(); int r = sequence.length(); int n = Math.floorDiv(r, 10); StringBuilder builder = new StringBuilder(r + n); for (int i = 0; i < r; i++) { switch (sequence.charAt(i)) { case 32: break; case 65: builder.append('U'); break; case 67: builder.append('G'); break; case 71: builder.append('C'); break; case 84: builder.append('A'); break; } } return builder.toString(); }
static Address mapLimit(final int units, final int heads) { // final int WORD_SIZE = ArchitecturalWord.getModel().bytesInWord(); final int WORD_SIZE = 4; return baseAddress.plus( Math.floorDiv(((units + heads + 1) * WORD_SIZE * 2) + (PAGE_SIZE - 1), PAGE_SIZE) * PAGE_SIZE); }
AbstractDate plusMonths(long months) { if (months == 0) { return this; } long curEm = getProlepticMonth(); long calcEm = Math.addExact(curEm, months); int newYear = Math.toIntExact(Math.floorDiv(calcEm, lengthOfYearInMonths())); int newMonth = (int) (Math.floorMod(calcEm, lengthOfYearInMonths()) + 1); return resolvePrevious(newYear, newMonth, getDayOfMonth()); }
public int averageWordLength(String text) { String[] words = extractWords(text); Integer totalLength = 0; if (words.length == 0) { return totalLength; } for (String word : words) { totalLength += word.length(); } return Math.floorDiv(totalLength, words.length); }
@Override public String setupSequence(String input) { String text = input.replaceAll("\\P{L}", ""); int l = text.length(); int n = Math.floorDiv(l, 10); StringBuilder builder = new StringBuilder(l + n); for (int i = 0; i < l; i++) { if (i > 9 && i % 10 == 0) builder.append(' '); switch (text.charAt(i)) { case 65: builder.append('A'); break; case 67: builder.append('C'); break; case 71: builder.append('G'); break; case 84: builder.append('T'); break; case 85: builder.append('U'); break; case 97: builder.append('A'); break; case 99: builder.append('C'); break; case 103: builder.append('G'); break; case 116: builder.append('T'); break; case 117: builder.append('U'); break; default: builder.append('N'); break; } } return builder.toString(); }
@Override public String getTranslatedText(int shift) { String sequence = getSequence(); sequence = sequence.replace(" ", ""); sequence = sequence.replace("T", "U"); sequence = sequence.substring(shift); int r = sequence.length(); int n = Math.floorDiv(r, 3); StringBuilder sb = new StringBuilder(n); for (int i = 0, j = 0; i < n; i++, j += 3) { sb.append(Conversion.getLetter(sequence.substring(j, j + 3))); } return sb.toString(); }
public static Quadrant getQuadrant(int x, int y) { return new Quadrant(1 + Math.floorDiv(x, 64), 1 + Math.floorDiv(y, 64)); }
private int findYear(long epochSecond, ZoneOffset offset) { // inline for performance long localSecond = epochSecond + offset.getTotalSeconds(); long localEpochDay = Math.floorDiv(localSecond, 86400); return LocalDate.ofEpochDay(localEpochDay).getYear(); }
/** * Returns a Frequency whose value is Math.floorDiv(this, value). * * @param value value to be divided by this Frequency * @return Math.floorDiv(this, value) */ public Frequency floorDivision(long value) { return new Frequency(Math.floorDiv(this.frequency, value)); }