08-18-2022, 09:59 PM
Here's the trick for subtracting string math -- it's just addition !!
-3 - 3... if the signs are the same, you just add the values and keep the sign. -3 + -3
3 - 4 or 4 - 3... if signs are different, the result will always be the sign of the largest number.
3 - 4 is 3 + -4. 4 is larger than 3, so we use the sign on the 4 for the result. (-) The swap a and b so a is 4, b is 3, and subtract up to 18 digits at a time.
That's all there is to it.
-3 - 3... if the signs are the same, you just add the values and keep the sign. -3 + -3
3 - 4 or 4 - 3... if signs are different, the result will always be the sign of the largest number.
3 - 4 is 3 + -4. 4 is larger than 3, so we use the sign on the 4 for the result. (-) The swap a and b so a is 4, b is 3, and subtract up to 18 digits at a time.
That's all there is to it.