<p>
Converts a big number to a friendly text representation. Accepts values
ranging from thousands to googols. Uses BigDecimal.
</p>

@param value
Number to be converted
@return Friendly text representation of the given value
549689
public static String spellBigNumber(final Number value)
    {
        BigDecimal v = new BigDecimal(value.toString());

        if (THOUSAND.compareTo(v.abs()) > 0)
            return value.toString();

        boolean isPlural = needPlural(v.unscaledValue().intValue());

        for (BigDecimal bigNum : bigDecExponents.keySet())
            if (bigNum.multiply(THOUSAND).compareTo(v.abs()) > 0)
                return context.get().formatMessage(
                        (isPlural) ? bigDecExponents.get(bigNum) + ".pl" : bigDecExponents.get(bigNum),
                        v.divide(bigNum));

        return value.toString();
    }
557124
public static int computeRawVarint64Size(final long value) {
        if ((value & (0xffffffffffffffffL << 7)) == 0) return 1;
        if ((value & (0xffffffffffffffffL << 14)) == 0) return 2;
        if ((value & (0xffffffffffffffffL << 21)) == 0) return 3;
        if ((value & (0xffffffffffffffffL << 28)) == 0) return 4;
        if ((value & (0xffffffffffffffffL << 35)) == 0) return 5;
        if ((value & (0xffffffffffffffffL << 42)) == 0) return 6;
        if ((value & (0xffffffffffffffffL << 49)) == 0) return 7;
        if ((value & (0xffffffffffffffffL << 56)) == 0) return 8;
        if ((value & (0xffffffffffffffffL << 63)) == 0) return 9;
        return 10;
    }
825016
public static Number parseNumber( String value ) {
        // Try to parse as a number ...
        char c = value.charAt(0);

        if ((c >= '0' && c <= '9') || c == '.' || c == '-' || c == '+') {
            // It's definitely a number ...
            if (c == '0' && value.length() > 2) {
                // it might be a hex number that starts with '0x'
                char two = value.charAt(1);
                if (two == 'x' || two == 'X') {
                    try {
                        // Parse the remainder of the hex number ...
                        return Integer.parseInt(value.substring(2), 16);
                    } catch (NumberFormatException e) {
                        // Ignore and continue ...
                    }
                }
            }
            // Try parsing as a double ...
            try {
                if ((value.indexOf('.') > -1) || (value.indexOf('E') > -1) || (value.indexOf('e') > -1)) {
                    return Double.parseDouble(value);
                }
                Long longObj = new Long(value);
                long longValue = longObj.longValue();
                int intValue = longObj.intValue();
                if (longValue == intValue) {
                    // Then it's just an integer ...
                    return new Integer(intValue);
                }
                return longObj;
            } catch (NumberFormatException e) {
                // ignore ...
            }
        }
        return null;
    }
944402
public static String byte2Hex(int value) {
    if (value > 255 || value < 0) {
      throw new IllegalArgumentException("The int converting to hex should be in range 0~255");
    }
    return String.valueOf(FIRST_CHAR[value]) + String.valueOf(SECOND_CHAR[value]);
  }
783712
public static BigInteger read(String value) {
		if (!StringUtils.hasText(value)) return null;
		
		return new BigInteger(value);
	}
262660
private static Number asNumber(Object value) {
    Number num = null;
    if (value == null) {
      num = null;
    } else if (value instanceof Number) {
      num = (Number) value;
    } else if (value instanceof Boolean) {
      num = ((Boolean) value) ? 1 : 0;
    }
    return num;
  }
403904
public static Number toNumber(Object value, Number defaultValue) {
		return convert(Number.class, value, defaultValue);
	}
719024
public static String getDigits(String value) {

    StringBuilder digits = new StringBuilder(value.length());

    for (char chr : value.toCharArray()) {
      if (Character.isDigit(chr)) {
        digits.append(chr);
      }
    }

    return digits.toString();
  }
1360617
public Integer convertToInt(String value) {
        Integer result = null;
        if (value != null) {
            result = Integer.valueOf(value);
        }
        return result;
    }
1062671
public static <T extends Number & Comparable<?>> NumberExpression<T> asNumber(T value) {
        return asNumber(constant(value));
    }
811160
public static Integer asInteger(Object value) {
    int intValue;
    switch (value.getClass().getCanonicalName()) {
      case "java.math.BigDecimal":
        intValue = ((BigDecimal) value).intValue();
        break;
      case "java.lang.Boolean":
        intValue = (Boolean) value ? 1 : 0;
        break;
      case "java.lang.Integer":
        intValue = (Integer) value;
        break;
      default:
        intValue = (Integer) value;
        break;
    }
    return intValue;
  }
497911
@Pure
	public static byte[] parseBELong(long value) {
		return new byte[] {
			(byte) ((value >> 56) & 0xFF),
			(byte) ((value >> 48) & 0xFF),
			(byte) ((value >> 40) & 0xFF),
			(byte) ((value >> 32) & 0xFF),
			(byte) ((value >> 24) & 0xFF),
			(byte) ((value >> 16) & 0xFF),
			(byte) ((value >> 8) & 0xFF),
			(byte) (value & 0xFF),
		};
    }
421262
public static String writeInteger(Integer value) {
		if (value==null) return null;
		
		return Integer.toString(value);			
	}
1107705
private String formatUnits(Number value)
   {
      return (value == null ? null : m_formats.getUnitsDecimalFormat().format(value.doubleValue() / 100));
   }
595820
public static String formatSize(final long value) {
        double size = value;
        DecimalFormat df = new DecimalFormat("#.##");
        if (size >= GB) {
            return df.format(size / GB) + " GB";
        }
        if (size >= MB) {
            return df.format(size / MB) + " MB";
        }
        if (size >= KB) {
            return df.format(size / KB) + " KB";
        }
        return String.valueOf((int) size) + " bytes";
    }
497402
public String convert(final String value) {

        if(!value.matches(".*[0-9].*")) {
            return value;
        }

        String str = value;
        for(int i=0; i < numMap.length; i++) {
            str = str.replaceAll(String.valueOf(i), numMap[i]);
        }

        return str;

    }
1271435
@Override
    protected String convertToString(Object value) throws Throwable {
		GeoPt geoPt = (GeoPt) value;
		return new BigDecimal(geoPt.getLatitude()) + "," + new BigDecimal(geoPt.getLongitude());
    }