NumberUtil { public static byte[] toAsciiBytes(Number i) { return BytesUtils.toASCIIBytes(String.valueOf(i).toCharArray()); }  static long unsigned32(int n); static int unsigned16(short n); static byte[] toAsciiBytes(Number i); static byte[] toAsciiBytes(short i); static byte[] toAsciiBytes(int i); static byte[] toAsciiBytes(long i); static byte[] toAsciiBytes(float i); static byte[] toAsciiBytes(double i); static double parseDouble(byte[] bytes, int start, int length); static int parseInt(byte[] bytes, int start, int length); static int parseInt(byte[] bytes, int start, int length, int radix); static long parseLong(byte[] bytes, int start, int length); static long parseLong(byte[] bytes, int start, int length, int radix); static void writeUTF8(OutputStream out, int i); static void writeUTF8(OutputStream out, long i); static double parseDouble(ByteBuf bytes); static double parseDouble(ByteBuf bytes, int start, int length); static int parseInt(ByteBuf bytes); static int parseInt(ByteBuf bytes, int start, int length); static int parseInt(ByteBuf bytes, int start, int length, int radix); static long parseLong(ByteBuf bytes); static long parseLong(ByteBuf bytes, int start, int length); static long parseLong(ByteBuf bytes, int start, int length, int radix); static Number numberValue(Class<?> numberClazz, String value); static long mergeToLong(int value1, int value2); static int toHighInt(long value); static int toLowInt(long value); static final double[] powersOf10; }
@Test public void testNumberToAsciiBytes() { Random r = new Random(System.currentTimeMillis()); Number n = r.nextInt(); assertArrayEquals(String.valueOf(n.shortValue()).getBytes(), NumberUtil.toAsciiBytes(n.shortValue())); n = r.nextInt(); assertArrayEquals(String.valueOf(n.intValue()).getBytes(), NumberUtil.toAsciiBytes(n.intValue())); n = r.nextLong(); assertArrayEquals(String.valueOf(n.longValue()).getBytes(), NumberUtil.toAsciiBytes(n.longValue())); n = r.nextFloat(); assertArrayEquals(String.valueOf(n.floatValue()).getBytes(), NumberUtil.toAsciiBytes(n.floatValue())); n = r.nextDouble(); assertArrayEquals(String.valueOf(n.doubleValue()).getBytes(), NumberUtil.toAsciiBytes(n.doubleValue())); }