0

Hey there.

I'm trying to figure out how to subtract one array of integers from another. I have figured out how to add 2 together going digit by digit and carrying over. I have no idea how to go about subtracting one from another. Basically i want to do simple calculations on numbers that long long wouldn't hold. I also want to do it using the standard library.

Does anyone have any hints on how to start or a link to a tutorial?

Any help is most appreciated.

2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by frogboy77
1

There might be a better way to do this, but this is just my idea:

1. determine sign of the result
2. make all cstring'd numbers positive
3. big number always goes on top
4. smaller number always goes on bottom
5. perform right-to-left subtraction just like you learned in 2nd grade.
6. apply proper sign to result

If anyone knows a better way to do this, let me know.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.