By "factored out", do you mean made into a source code macro?
Or do you mean made into a separate procedure/function?
Separate procedures/functions would slow down the code.
I mean functions/procedures.
It may slow down (a bit), but imagine that you need to alter that code just slightly (perhaps a bugfix or a faster algorithm), then you would have to alter it in many places.
Alternatively, if you always use the same variable names, then you can put the code for e.g. overlow checking in an include file and include that file everywhere you need that code.
I've done a similar thing in
my utf8cpstrict unit, re-using the
same piece of code in several functions (with a little macro help).
(Or define the pice of code as a macro, but the debugger really doesn't like it and compiler and runtime errors tend to show up in the wrong line.)
PS: I also saw you using labels and goto's simply to jum to the end of a procedure.
That's what you can use the Exit statement for.
I would really encourage you to try to improve readabilty and maintainability of your code.
Bart
PS. I wrote my own biginteger library, which allows in theory for up to 2^32 digits, implementing all basic functions (add, subtract, multiply, divide) using the logic we were told in primary school (so it does longdivision).
It's just a silly pet project (and really slow. In theory it can calculate 10000 factorial (and more), but it may take several days to calculate that, I never had the courage to test.).
It also does conversion to any base (well, base 2 to base 36).
And it is nullable (not really usefull, but hey, if you can add more complexity, why not?).