JAVA计算整数的位数

    /**
     * 计算整数的位数
     * @param x
     * @return
     */
    public static int countIntegerLength(int x){
        final int [] sizeTable = { 9, 99, 999, 9999, 99999, 999999, 9999999,
                99999999, 999999999, Integer.MAX_VALUE };

        for (int i=0; ; i++)
            if (x <= sizeTable[i]){
                return i+1;
            }
    }

原文地址:https://www.cnblogs.com/bryanx/p/8723516.html