You can use negative numbers in the text file and still += to get the same result, however you'd run into the same problem if you wanted * and / for instance. I'd sugget writing a parser that gets each token in the text file by whitespace and create a FSM to conclude what should happen on each token. Bjarne Stroustrup creates one in his book if you are able to get it. It's a great start, the code eventually evolves into handling brackets and being able to write var1=30 and so on, making a little basic parser it's pretty nifty.