Basically it works like this:
Code:
string: 150
sum: 0
pointer to the character 1
begin loop
sum = sum * 10
sum = sum + the number pointer is pointing to
move pointer to next character
if we aren't pointing to the end of the string, repeat the loop
end loop
sum now holds the value
broken down by example (loop unrolled)
Code:
string = 125
sum = 0
sum = sum * 10 // 0 * 10 is still 0
sum = sum + 1 // Now sum is 1
sum = sum * 10 // Now sum is 10
sum = sum + 2 // Now sum is 12
sum = sum * 10 // Now sum is 120
sum = sum + 5 // Now sum is 125