4 ms·
Perhaps an easier way would be to just do normal long division just in base 2.
by air7 7y ago
Perhaps an easier way would be to just do normal long division just in base 2.
- sgdpk 7y agoThis actually is the long division algorithm. Usually the positional system hides away the powers of 10 (or 2 in this case) so we can do it mechanically and fast. He is just going through the algorithm explicitly.
- jonsen 7y agoAn easier easier way: 1/3 = 0.3333... = 0.????...b *2 = 0.6666... 0 -> 0.0???...b *2 = 1.3333... 1 -> 0.01??...b -1 = 0.3333... *2 = 0.6666... 0 -> 0.010?...b etc.
- dTal 7y agoThis is insightful, but hard to read. Essentially: 1/3 * 4 = 4/3 4/3 = 1 + 1/3 So, working backwards, our number can be more and more closely approximated by repeatedly adding 1 and dividing by 4 - or in binary, prepending a 1 and shifting two places right: 0.01010101...
- air7 7y agoNice. Maybe an easier^3 could be: 1/3 = 0.xyz 4/3 = 1.xyz Meaning (shl,2) leaves the same digits after the decimal point. So it must be 0.010101...