From ae25ca294b05e1f416a1a158922730695fe9d31a Mon Sep 17 00:00:00 2001 From: michaelangel007 Date: Wed, 5 Feb 2020 09:39:52 -0800 Subject: [PATCH] Fix algorithm step 2 description C code --- README.MD | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.MD b/README.MD index 8c35f75..82a2727 100644 --- a/README.MD +++ b/README.MD @@ -35,7 +35,7 @@ An alternative algorithm to implement multiplication using only: # Algorithm 1. Initialize Sum <- zero. In C nomenclature: `Sum = 0;` -2. If B is odd then add A to Sum. In C nomenclature: `Sum += A;` +2. If B is odd then add A to Sum. In C nomenclature: `if( B & 1 ) Sum += A;` 3. Multiply A by 2 -- that is, Shift A **left** by one. In C nomenclature: `A <<= 1;` 4. Divide B by 2 -- that is, Shift B **right** by one. In C nomenclature: ` B >>= 1;` 5. If B is zero then STOP. `while( b ) { ... }`