Do school mathematics , compute difference of current digits and carry
int sub = ( ( ( int ) str1 [ i + diff ] - ( int ) '0' ) - ( ( int ) str2 [ i ] - ( int ) '0' ) - carry ) ; if ( sub < 0 ) { sub = sub + 10 ; carry = 1 ; } else carry = 0 ; str += sub . ToString ( ) ; }