Java示例

  1. 依次打印long类型数字各位上的数:
    private void longPrint(){
        long Xmask = 212321323144L;
        long sum = Xmask;
        long total = 0L;
        long current = 0L;

        for(int index = 1; index < 13; index++){
            total = sum;
            sum = sum / 10;
            current = total - sum * 10;
            Log.d(TAG, "@justinTest current: " + current);
        }
        /*
        long firstValue = Xmask / (long)(Math.pow(10, 11)); 
        Log.d(TAG, "@justinTest current: " + current);
        Xmask = Xmask - firstValue * (long)(Math.pow(10, 11));
        Log.d(TAG, "@justinTest Xmask: " + Xmask);
        */
        for(int index = 0, count = 13; index < 12; index++, count--){
            long currentValue = Xmask / (long)(Math.pow(10, count-2));  
            Xmask = Xmask - currentValue * (long)(Math.pow(10, count-2));
            Log.d(TAG, "@justinTest currentValue:"+currentValue+" Xmask: " + Xmask);
        }
    }

你可能感兴趣的:(Java)