List of utility methods to do Bit Shift
int | shift(int a, int b) shift if ((0 < b) && (b < 32)) { return a << b; } else if ((-32 < b) && (b < 0)) { return a >> (-b); } else if (b == 0) { return a; } else if (b >= 32) { return 0; ... |
int | shift(int component, int shift) Bit shifts a color component, loosing the less significant bits return component >> shift;
|
long | shift(int direction, long sq, int delta) shift long result = sq; for (int i = 0; i < delta; i++) { result = shift(direction, result); return result; |
int | shift(int length) shift int shift = 1; int shifted = 2; while (shifted <= length) { ++shift; shifted <<= 1; return shift; |
String | shift(String string) shift StringBuilder builder = new StringBuilder(); final String[] strings = string.split("\n"); for (String s : strings) { builder.append(" ").append(s).append("\n"); return builder.toString(); |
byte | shiftBits(byte b) shift Bits int upper = b << 4 & b1; int lower = b >> 4 & b2; return (byte) (upper | lower); |
byte | shiftByte(byte n, short shift) shift Byte if (shift > 0) { return (byte) (n << shift); } else { return (byte) (n >> -shift); |
char | shiftCharacter(char c, int offset) shift Character return (char) (c + offset); |
String | shiftDouble(Object o, double shift, String suffix) shift Double Double d = parseDouble(o); d = d + shift; return (String.format("%.1f", d) + suffix); |
int | shiftHorizontally(int inkX, int inkXWidth, int textWidth) Returns a shift of 'x' coordinate in pixels in order to fit the logical extent horizontally if ((inkX < 0) && (inkXWidth <= textWidth)) { return inkX; if ((inkX + inkXWidth > textWidth) && (inkXWidth <= textWidth)) { return (inkX + inkXWidth - textWidth); return 0; |