2016-05-05 5 views
1
import 'dart:io'; 

void main() { 
double base = 1, bnry = 0, remainder = 0, ans = 0, inp; 
print("Please input binary number : "); 
inp = stdin.readLineSync(); 
bnry = inp; 
while(inp < 1){ 
    remainder = inp % 10; 
    ans = ans + remainder * base; 
    base = base * 2; 
    inp = inp/10; 
} 
print("$inp"); 
} 

を使用して、このマイナーなエラーを持つことは、このここに私のコードで、あなたがstdin.readLineSync()から文字列を取得し、エラーメッセージダート

unhandled exception: Class 'String' has no instance method '<'. NoSuchMethodError: method not found: '<'

答えて

1

です。それを他の番号と比較できるように番号に変換する必要があります

inp = num.parse(stdin.readLineSync()); 
関連する問題