display | more...

Borrow is the opposite of carry. It occurs when breaking through the lower bound of modulo arithmetic.

In computer science: when subtracting one unsigned register from a similar-sized unsigned register, a borrow occurs when the result is negative. A borrow flag is set when this occurs - it is cleared when a subtraction does not result in a negative number. The borrow flag is useful for multiple-word arithmetic: given a 2-word value AB (register A holding the most significant word, register B being the least significant word), to subtract a 1-word value C: First subtract C from B. If this causes a borrow, decrement A. If the decrement causes a borrow also, then the overall result is negative and is stored in 2's complement form in AB, otherwise the result is positive (or zero) and is correctly stored in unsigned form in AB.

Because of this, many machine code instruction sets include not only a 'subtract' instruction, but also a 'subtract with borrow' instruction. To subtract a 3-word value DEF from ABC, then, the pseudocode would look something like:
``` clear the borrow flag subtract with borrow, F from C subtract with borrow, E from B subtract with borrow, D from A ``` (The first two instructions could be replaced with a single regular 'subtract' instruction... the verbosity is intentional, to illustrate the pattern that is at work here.) If the borrow is set after all that, the result is negative.

Also called unsigned underflow.