List of utility methods to do Number Convert
int | numToBytes(byte[] buffer, long value) Place a string representation of a long in an array of bytes without incurring allocation return numToBytes(buffer, value, 10);
|
int | numToBytes(byte[] buffer, long value, int radix) num To Bytes return 0;
|
void | numToBytes(long value, byte[] b, int off, int len) Writes a signed integer into a byte array. long shift = value; for (int i = len - 1; i >= 0; i--) { long v = shift & 0xff; if ((v & 0x80) > 0) { v -= 0x100; b[off + i] = (byte) v; shift = shift >> 8; ... |
Integer | numToInt(Number n) Converts a Number object into an Integer. return (Integer) (n.intValue());
|
String | numToIPv4(StringBuilder host) num To I Pv int i = findFirstMatch(host, ":/?", 0); if (i < 0) { i = host.length(); return numToIPv4(host, 0, i); |
String | numToLetter(String input) num To Letter StringBuffer sb = new StringBuffer(); byte[] bytes = input.getBytes(); for (int i = 0; i < bytes.length; i++) { if (i % 2 == 0) { sb.append((char) (bytes[i] + 49)); } else { sb.append((char) (bytes[i] + 17)); return sb.toString(); |
int | numToPowerOf(int num, int toPowerOf) num To Power Of return toPowerOf > 0 ? num << toPowerOf : (toPowerOf < 0 ? num >> toPowerOf : (toPowerOf == 0 ? 1 : num));
|
String | numToStringWithOrder(long count) num To String With Order if (count < 1000) { return "" + count; int exp = (int) (Math.log(count) / Math.log(1000)); return String.format("%.1f %c", count / Math.pow(1000, exp), "KMGTPE".charAt(exp - 1)); |
String | numToWords(long num) Gets a word from a number in between 1-999 String[] ones = new String[] { "one", "two", "three", "four", "five", "six", "seven", "eight", "nine" }; int[] onesLen = new int[] { 3, 3, 5, 4, 5, 3, 5, 5, 4 }; String[] teens = new String[] { "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen" }; int[] teensLen = new int[] { 6, 6, 8, 8, 7, 7, 9, 8, 8 }; String[] tens = new String[] { "ten", "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety" }; int[] tensLen = new int[] { 3, 5, 6, 5, 5, 5, 7, 6, 6 }; ... |
double | parseAmountConversionRate(String convRate) Parse currency amount conversion rate string Suitble for parse fields 10 and 11 if (convRate == null || convRate.length() != 8) throw new IllegalArgumentException("Invalid amount converion rate argument: '" + convRate + "'"); BigDecimal bd = new BigDecimal(convRate); int pow = bd.movePointLeft(7).intValue(); bd = new BigDecimal(convRate.substring(1)); return bd.movePointLeft(pow).doubleValue(); |