int類(lèi)型變量范圍超過(guò)了2147483648就錯(cuò)誤,如果數(shù)值是10位以上用什么數(shù)據(jù)類(lèi)型?
public class HelloWorld{
public static void main(String[] args){
int num = 2147483648 ;
int count = 0;
? ? if(num>=0 && num<=999999999){
? ? ? ? for(count=0;count<10;){
? ? ? ? ? count++;
? ? ? ? ? num/=10;
? ? ? ? ? if(num==0){
? ? ? ? ? ? ?break;
? ? ? ? ? ? }
? ? ? }
? ? ? System.out.println("它是個(gè)"+count+"位的數(shù)!");? }
? ? else{
? ? ? ? ? ?System.out.println("輸入有誤!");
? ? }
? ? ?
}
}
2019-05-22
用long 數(shù)值后面加小寫(xiě)l
2019-07-15
?長(zhǎng)整型