Javaの例

2570 ワード

  • 順次印刷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);
            }
        }