Hacker News new | past | comments | ask | show | jobs | submit login

An 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.



This 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...


Nice. 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...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: