Doing binary arithmetic in Windows Calculator and

Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
3 replies · 4K views
bitrex
Messages
190
Reaction score
0
I was doing some conversions from binary to decimal and vice versa today using Windows Calculator and I noticed the following, if I multiply B11111111 and B11111111 I get the following: B1111111000000001. Uhhh...great! What's going on here? It looks like it's rolling over the 8 LSB when it shouldn't, or something...:confused:
 
Mathematics news on Phys.org
No, it's just giving you the right answer, as remarkable as that might seem!

B11111111 is just 28-1= 255. B11111111 times B11111111 is the same as 255(255)= 62025 which, in binary, is B1111111000000001.

In more detail: B11111111 is, as I said, 28-1. B11111111 times B11111111 is (28- 1)(28- 1)= (28)2- 2(28)+ 1= 216- 29+ 1. 216- 29= 29(216- 9-1)= 29(27-1). That "27-1" is the reason for the 7 "1"s leading the number. That 29 is the reason it is followed by 9 "0"s- or would be if it were not for that final "+ 1".
 
HallsofIvy said:
In more detail: B11111111 is, as I said, 28-1. B11111111 times B11111111 is (28- 1)(28- 1)= (28)2- 2(28)+ 1= 216- 29+ 1. 216- 29= 29(216- 9-1)= 29(27-1). That "27-1" is the reason for the 7 "1"s leading the number. That 29 is the reason it is followed by 9 "0"s- or would be if it were not for that final "+ 1".

Nice explanation, HallsofIvy. You may be interested in another binary pattern I discovered recently: integers made up of n digits of 9s have binary representations that have exactly n digits of trailing 1s (e.g., 9,999,999 is 100110001001011001111111 in binary). I proved it here: http://www.exploringbinary.com/nines-in-binary/ .
 
Thanks for the explanation! After thinking about it, I see the flaw in my reasoning. I was expecting B11111111 * B11111111 to become B1111111111111111, remembering that when doing it out longhand the partial product of the multiplicand is always 1 if it and the multiplier are 1. Since there are no zeros in either of them, I expected the result to have no zeros also. However, I was forgetting about the "placeholder" zeros that accumulate as the partial products are shifted left.