@Test public void testGetUnsigndeAlignedValue() { assertEquals(0, NumericUtilities.getUnsignedAlignedValue(0xffffffffffffffffL, 8)); assertEquals(0xfffffffffffffff8L, NumericUtilities.getUnsignedAlignedValue(0xfffffffffffffff8L, 8)); assertEquals(0xfffffffffffffff8L, NumericUtilities.getUnsignedAlignedValue(0xfffffffffffffff3L, 8)); assertEquals(0xfffffffffffffff0L, NumericUtilities.getUnsignedAlignedValue(0xffffffffffffffecL, 8)); assertEquals(0xffffffffffffffe8L, NumericUtilities.getUnsignedAlignedValue(0xffffffffffffffe8L, 8)); assertEquals(0, NumericUtilities.getUnsignedAlignedValue(0, 8)); assertEquals(8, NumericUtilities.getUnsignedAlignedValue(3, 8)); assertEquals(8, NumericUtilities.getUnsignedAlignedValue(8, 8)); assertEquals(0, NumericUtilities.getUnsignedAlignedValue(0xffffffffffffffffL, 5)); assertEquals(0xfffffffffffffffbL, NumericUtilities.getUnsignedAlignedValue(0xfffffffffffffff8L, 5)); assertEquals(0xfffffffffffffff6L, NumericUtilities.getUnsignedAlignedValue(0xfffffffffffffff3L, 5)); assertEquals(0xffffffffffffffecL, NumericUtilities.getUnsignedAlignedValue(0xffffffffffffffecL, 5)); assertEquals(0xffffffffffffffecL, NumericUtilities.getUnsignedAlignedValue(0xffffffffffffffe8L, 5)); assertEquals(0, NumericUtilities.getUnsignedAlignedValue(0, 5)); assertEquals(5, NumericUtilities.getUnsignedAlignedValue(3, 5)); assertEquals(0xa, NumericUtilities.getUnsignedAlignedValue(8, 5)); }
public static long getUnsignedAlignedValue(long unsignedValue, long alignment) { if (unsignedValue % alignment == 0) { return unsignedValue; } boolean negative = unsignedValue < 0; if (negative) { unsignedValue = -(unsignedValue + alignment); } long alignedValue = ((unsignedValue + alignment - 1) / alignment) * alignment; if (negative) { alignedValue = -alignedValue; } return alignedValue; }
NumericUtilities { public static long getUnsignedAlignedValue(long unsignedValue, long alignment) { if (unsignedValue % alignment == 0) { return unsignedValue; } boolean negative = unsignedValue < 0; if (negative) { unsignedValue = -(unsignedValue + alignment); } long alignedValue = ((unsignedValue + alignment - 1) / alignment) * alignment; if (negative) { alignedValue = -alignedValue; } return alignedValue; } }
NumericUtilities { public static long getUnsignedAlignedValue(long unsignedValue, long alignment) { if (unsignedValue % alignment == 0) { return unsignedValue; } boolean negative = unsignedValue < 0; if (negative) { unsignedValue = -(unsignedValue + alignment); } long alignedValue = ((unsignedValue + alignment - 1) / alignment) * alignment; if (negative) { alignedValue = -alignedValue; } return alignedValue; } private  NumericUtilities(); }
NumericUtilities { public static long getUnsignedAlignedValue(long unsignedValue, long alignment) { if (unsignedValue % alignment == 0) { return unsignedValue; } boolean negative = unsignedValue < 0; if (negative) { unsignedValue = -(unsignedValue + alignment); } long alignedValue = ((unsignedValue + alignment - 1) / alignment) * alignment; if (negative) { alignedValue = -alignedValue; } return alignedValue; } private  NumericUtilities(); static long parseNumber(String numStr); static long parseLong(String numStr); static long parseOctLong(String numStr); static long parseHexLong(String numStr); static BigInteger parseHexBigInteger(String numStr); final static String toHexString(long value); final static String toHexString(long value, int size); final static String toSignedHexString(long value); final static BigInteger unsignedLongToBigInteger(long value); final static long bigIntegerToUnsignedLong(BigInteger value); static long getUnsignedAlignedValue(long unsignedValue, long alignment); static String convertMaskedValueToHexString(long msk, long val, int n, boolean truncate,
			int spaceevery, String spacer); static String convertMaskToHexString(long msk, int n, boolean truncate, int spaceevery,
			String spacer); static void convertHexStringToMaskedValue(AtomicLong msk, AtomicLong val, String hex,
			int n, int spaceevery, String spacer); static String formatNumber(long number, int radix); static String formatNumber(long number, int radix, SignednessFormatMode mode); static byte[] convertStringToBytes(String hexString); static String toString(byte b); static String convertBytesToString(byte[] bytes); static String convertBytesToString(byte[] bytes, String delimeter); static String convertBytesToString(byte[] bytes, int start, int len, String delimeter); static String convertBytesToString(Iterator<Byte> bytes, String delimiter); static String convertBytesToString(Iterable<Byte> bytes, String delimiter); static String convertBytesToString(Stream<Byte> bytes, String delimiter); static boolean isIntegerType(Number number); static boolean isIntegerType(Class<?> numClass); static boolean isFloatingPointType(Number number); static boolean isFloatingPointType(Class<?> numClass); }
NumericUtilities { public static long getUnsignedAlignedValue(long unsignedValue, long alignment) { if (unsignedValue % alignment == 0) { return unsignedValue; } boolean negative = unsignedValue < 0; if (negative) { unsignedValue = -(unsignedValue + alignment); } long alignedValue = ((unsignedValue + alignment - 1) / alignment) * alignment; if (negative) { alignedValue = -alignedValue; } return alignedValue; } private  NumericUtilities(); static long parseNumber(String numStr); static long parseLong(String numStr); static long parseOctLong(String numStr); static long parseHexLong(String numStr); static BigInteger parseHexBigInteger(String numStr); final static String toHexString(long value); final static String toHexString(long value, int size); final static String toSignedHexString(long value); final static BigInteger unsignedLongToBigInteger(long value); final static long bigIntegerToUnsignedLong(BigInteger value); static long getUnsignedAlignedValue(long unsignedValue, long alignment); static String convertMaskedValueToHexString(long msk, long val, int n, boolean truncate,
			int spaceevery, String spacer); static String convertMaskToHexString(long msk, int n, boolean truncate, int spaceevery,
			String spacer); static void convertHexStringToMaskedValue(AtomicLong msk, AtomicLong val, String hex,
			int n, int spaceevery, String spacer); static String formatNumber(long number, int radix); static String formatNumber(long number, int radix, SignednessFormatMode mode); static byte[] convertStringToBytes(String hexString); static String toString(byte b); static String convertBytesToString(byte[] bytes); static String convertBytesToString(byte[] bytes, String delimeter); static String convertBytesToString(byte[] bytes, int start, int len, String delimeter); static String convertBytesToString(Iterator<Byte> bytes, String delimiter); static String convertBytesToString(Iterable<Byte> bytes, String delimiter); static String convertBytesToString(Stream<Byte> bytes, String delimiter); static boolean isIntegerType(Number number); static boolean isIntegerType(Class<?> numClass); static boolean isFloatingPointType(Number number); static boolean isFloatingPointType(Class<?> numClass); static final BigInteger MAX_UNSIGNED_LONG; static final BigInteger MAX_SIGNED_LONG; }