Failing for large testcase


#1
int Solution::power(string s) {
    if(s=="1") return 0;
    string num="";
    int i=0,borrow=0;
    while(s.size()!=1) {
        i=0;
        while(i<s.size()) {
            int digit = borrow*10 + ((int)s[i]-'0');
            borrow=digit%2;
            if(digit==1){
                i++;
            } else {
                digit/=2;
                num += to_string(digit);
                i++;
            }
        }
        // cout<<num<<endl;
        if(((int)num[num.size()-1])%2!=0) return 0;
        s=num;
        num="";
    }
    return 1;
}

This fails for 147573952589676412928
Any ideas?