您的位置:首页 > 编程语言 > Java开发

Java示例

2016-04-12 23:15 441 查看
依次打印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);
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: