- Subtract the subtrahend from a number that has as many nines as digits the numbers in the subtraction have (e.g. if the largest number in the operation is 176, you subtract that number from 999; if it is 3456, you subtract that number from 9999). This results in the nines' complement.
- Add the result to the original minuend.
- Finally, add 1 and subtract 1000.
lunes, 28 de julio de 2008
Subtracting without borrowing.
Petzold's book is full of excellent morsels of computer wisdom... as well as useful tips on mathematics. For example, while discussing the complexities of carrying out addition and subtraction operations on a computer, he shares with us a method to perform subtractions without borrowing (pp. 143-145):
No hay comentarios:
Publicar un comentario