What number in binary can only be represented as an approximation?

前端 未结 10 711
礼貌的吻别
礼貌的吻别 2021-01-16 12:10

In decimal (base 10), 1/3 can only be approximated to 0.33333 repeating.

What number is the equivalent in binary that can only be represented as an app

10条回答
  •  情话喂你
    2021-01-16 12:21

    It's every number that can't be expressed as k/2^n for integer k and whole number n.

    The easy way to find all these numbers is to write down some prime numbers that do not include 2. 3, 5, 7, 11, 13, 17 and 19 are good examples of prime numbers that don't include 2.

    Start multiplying. 1/3, 2/3, 1/5, 2/5, 3/5, 4/5, 1/6, 5/6, 1/7, 2/7, etc.

    if you do this -- and you avoid numbers of the form k/2^n -- you'll enumerate every possible fraction that cannot be exactly represented in binary.

    You should probably stop enumerating when you get to numbers for which the left-most 64-bits are all identical.

提交回复
热议问题