Operations on numbers represented as strings

Hello everyone,

I would like to make few functions that would allow me to execute mathematical operations on numbers in strings.

What I would like to achieve, is something like this:

Using function add:

Input:
"15"
"32"
and result:
47

Using function substract:

Input:
"300"
"157"
Result:
143

Using function square:

Input:
"2"
"3"
Result:
8

etc.

Is there some easy way? Because I don't see any. I don't have idea where to start. Could anyone help me please?

PS. I don't want to parse strings to change them to numbers. I want to operate on very basic numbers, like you would do on paper.
Start with the addition. How did you learn it in school in the very early educational levels? How do you do it on paper without shortcuts or memorization?

From right to left, you add the two digits (you will unfortunately HAVE to convert at least the digits to numbers for this) and if the result is two digits, use the first digits (the right-most one) as the current new digit's value, and the second digit (the left one) to be added in the next pair of digits.
Topic archived. No new replies allowed.