# Batch file subtraction



## tywaser1 (Jun 13, 2008)

I need a batch file that can subtract big numberssuch as:
789545184784
-
775739784768
=
13805400016.
Pease help. Set /a won't work because my numbers are too big.:sigh:


----------



## TheOutcaste (Mar 19, 2009)

Post what you have so far.
Basically you need to determine the number of digits in each number, pad the smaller one with leading zeros so they are the same length, then subtract the smaller number from the larger number one digit at a time, keeping track of whether or not you had to borrow.
If you swapped the numbers, the answer will be negative.
Example, A-B=C
If B is the larger number you Multiply both sides by -1 which gives -A+B=-C, or B-A=-C

Set /A can handle all 9 digit numbers, so another option is to split each number into 9 digit pieces, subtract them, then put them back together.


----------

